public void CreateCustomer(CustomerDto dto) { if (dto.Photo != null) { Repository.Create(dto.ToCustomer()); } }
public async Task <CustomerDto> CreateCustomer(CustomerDto customer) { if (!CustomerIsValid(customer)) { return(null); } var newCustomer = await _customerRepository.CreateCustomer(customer.ToCustomer()); return(newCustomer?.ToDto()); }
public async Task <bool> UpdateCustomer(CustomerDto customer) { if (!CustomerIsValid(customer)) { return(false); } var existingCustomer = await _customerRepository.FetchCustomerById(customer.Id); if (existingCustomer is null) { return(false); } OverloadExistingCustomer(existingCustomer, customer.ToCustomer()); return(await _customerRepository.UpdateCustomer(existingCustomer)); }
public async Task <ActionResult <CustomerDto> > Put(CustomerDto customer) { await _customerService.Update(customer.ToCustomer()); return(Ok()); }
public async Task <ActionResult <CustomerDto> > Post(CustomerDto customer) { await _customerService.Create(customer.ToCustomer()); return(Created($"/api/customer/{customer.CustomerId}", customer)); }