| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using Karsha_Site.Application.Interfaces.Contexts;
- using Karsha_Site.Common.Dto;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Karsha_Site.Application.Services.Costomers.Commands.RemoveCustomers
- {
- public interface IRemoveCategoriesService
- {
- ResultDto Execute(int customerId);
- }
- public class RemoveCustomerService : IRemoveCategoriesService
- {
- private readonly IDataBaseContext _context;
-
- public RemoveCustomerService(IDataBaseContext context)
- {
- _context = context;
- }
-
-
- public ResultDto Execute(int customerId)
- {
-
- var customer = _context.Customers.Find(customerId);
- if (customer == null)
- {
- return new ResultDto
- {
- IsSuccess = false,
- Message = "مشتری یافت نشد"
- };
- }
- customer.RemoveTime = DateTime.Now;
- customer.IsRemoved = true;
- _context.SaveChanges();
- return new ResultDto()
- {
- IsSuccess = true,
- Message = "مشتری با موفقیت حذف شد"
- };
- }
- }
- }
|