public void CreateCustomer(CustomerDto dto)
 {
     if (dto.Photo != null)
     {
         Repository.Create(dto.ToCustomer());
     }
 }
Exemple #2
0
        public async Task <CustomerDto> CreateCustomer(CustomerDto customer)
        {
            if (!CustomerIsValid(customer))
            {
                return(null);
            }

            var newCustomer = await _customerRepository.CreateCustomer(customer.ToCustomer());

            return(newCustomer?.ToDto());
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        public async Task <ActionResult <CustomerDto> > Put(CustomerDto customer)
        {
            await _customerService.Update(customer.ToCustomer());

            return(Ok());
        }
Exemple #5
0
        public async Task <ActionResult <CustomerDto> > Post(CustomerDto customer)
        {
            await _customerService.Create(customer.ToCustomer());

            return(Created($"/api/customer/{customer.CustomerId}", customer));
        }