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.

IRemoveAboutAddressService.cs 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Karsha_Site.Application.Interfaces.Contexts;
  2. using Karsha_Site.Common.Dto;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Karsha_Site.Application.Services.About.Commands.RemoveAboutAddress
  9. {
  10. public interface IRemoveAboutAddressService
  11. {
  12. ResultDto Execute(int customerId);
  13. }
  14. public class RemoveCustomerService : IRemoveAboutAddressService
  15. {
  16. private readonly IDataBaseContext _context;
  17. public RemoveCustomerService(IDataBaseContext context)
  18. {
  19. _context = context;
  20. }
  21. public ResultDto Execute(int aboutAddressId)
  22. {
  23. var customer = _context.AboutAddress.Find(aboutAddressId);
  24. if (customer == null)
  25. {
  26. return new ResultDto
  27. {
  28. IsSuccess = false,
  29. Message = "آدرس یافت نشد"
  30. };
  31. }
  32. customer.RemoveTime = DateTime.Now;
  33. customer.IsRemoved = true;
  34. _context.SaveChanges();
  35. return new ResultDto()
  36. {
  37. IsSuccess = true,
  38. Message = "آدرس با موفقیت حذف شد"
  39. };
  40. }
  41. }
  42. }