コード例 #1
0
        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)));
        }
コード例 #2
0
 public async Task <IActionResult> GetCustomerById(CustomerDTO_ToUpdate customer, int id)
 {
     return(Ok(await _customerService.UpdateCustomer(customer, id)));
 }