public async Task <ServiceResponse <CustomerDTO_ToRetun> > UpdateCustomer(CustomerDTO_ToUpdate UpdateACustomer, int id) { var oldCustomerData = await _dbContext.Customers.FirstOrDefaultAsync(x => x.Id == id); if (oldCustomerData.Name != UpdateACustomer.Name || oldCustomerData.MobilePhone != UpdateACustomer.MobilePhone || oldCustomerData.Email != UpdateACustomer.Email) { oldCustomerData.Name = UpdateACustomer.Name; oldCustomerData.MobilePhone = UpdateACustomer.MobilePhone; oldCustomerData.Email = UpdateACustomer.Email; oldCustomerData.IdCardNumber = UpdateACustomer.IdCardNumber; await _dbContext.SaveChangesAsync(); } return(ResponseResult.Success(_mapper.Map <CustomerDTO_ToRetun>(oldCustomerData))); }
public async Task <IActionResult> GetCustomerById(CustomerDTO_ToUpdate customer, int id) { return(Ok(await _customerService.UpdateCustomer(customer, id))); }