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

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

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

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

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