You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IEditAboutAddressService.cs 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Karsha_Site.Application.Interfaces.Contexts;
  2. using Karsha_Site.Common.Dto;
  3. using Microsoft.AspNetCore.Hosting;
  4. using Microsoft.AspNetCore.Http;
  5. using Microsoft.EntityFrameworkCore;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace Karsha_Site.Application.Services.Costomers.Commands.EditAboutAddress
  12. {
  13. public interface IEditAboutAddressService
  14. {
  15. ResultDto Execute(RequestEditaboutAddressDto request);
  16. }
  17. public class EditAboutAddressService : IEditAboutAddressService
  18. {
  19. private readonly IDataBaseContext _dataBaseContext;
  20. public EditAboutAddressService(IDataBaseContext context)
  21. {
  22. _dataBaseContext = context;
  23. }
  24. ResultDto IEditAboutAddressService.Execute(RequestEditaboutAddressDto request)
  25. {
  26. var aboutAddress = _dataBaseContext.AboutAddress.Find(request.ID);
  27. if (aboutAddress == null)
  28. {
  29. return new ResultDto
  30. {
  31. IsSuccess = false,
  32. Message = "آدرس یافت نشد"
  33. };
  34. }
  35. aboutAddress.IsMain = request.IsMain;
  36. aboutAddress.Address = request.Address;
  37. aboutAddress.DisplayName = request.DisplayName;
  38. aboutAddress.UpdateTime = DateTime.Now;
  39. _dataBaseContext.SaveChanges();
  40. return new ResultDto()
  41. {
  42. IsSuccess = true,
  43. Message = "ویرایش آدرس انجام شد"
  44. };
  45. }
  46. }
  47. public class RequestEditaboutAddressDto
  48. {
  49. public int ID { get; set; }
  50. public string DisplayName { get; set; }
  51. public string Address { get; set; }
  52. public bool IsMain { get; set; }
  53. public int AboutID { get; set; }
  54. }
  55. }