public async Task <GetCustomerPayDTO> Handle(PutCustomerPayCommand request, CancellationToken cancellationToken) { var data = await _context.customerPayCard.FindAsync(request.Data.Attributes.Id); data.customer_id = request.Data.Attributes.customer_id; data.name_on_card = request.Data.Attributes.name_on_card; data.exp_month = request.Data.Attributes.exp_month; data.exp_year = request.Data.Attributes.exp_year; data.postal_code = request.Data.Attributes.postal_code; data.credit_card_number = request.Data.Attributes.credit_card_number; _context.SaveChanges(); return(new GetCustomerPayDTO { Success = true, Message = "Success retreiving data", Data = new CustomerPayData { Id = data.Id, Customer_id = data.customer_id, Name_on_card = data.name_on_card, Exp_month = data.exp_month, Exp_year = data.exp_year, Postal_code = data.postal_code, Credit_card_number = data.credit_card_number } }); }
public async Task <GetCustomerDTO> Handle(PutCustomerCommand request, CancellationToken cancellationToken) { var data = await _context.customers.FindAsync(request.Data.Attributes.Id); data.full_name = request.Data.Attributes.full_name; data.username = request.Data.Attributes.username; data.birthdate = request.Data.Attributes.birthdate; data.email = request.Data.Attributes.email; data.phone_number = request.Data.Attributes.phone_number; data.update_at = DateTime.Now; _context.SaveChanges(); return(new GetCustomerDTO { Message = "Success retreiving data", Success = true, Data = new CustomerData { Id = data.Id, Full_name = data.full_name, Username = data.username, Birthdate = data.birthdate, Password = data.password, Gender = Enum.GetName(typeof(Gender), data.sex), Email = data.email, Phone_number = data.phone_number } }); }