//[Route("api/Customer")] public async Task <IActionResult> PostCustomer(CustomerPostDTO customerPostDTO) { var customer = _mapper.Map <Customer>(customerPostDTO); await _customerService.InsertCustomer(customer); return(Ok(customer)); }
public async Task <ActionResult <CustomerResponseDTO> > CustomerInsert(CustomerPostDTO customerPostDTO) { // Map customerPostDTO to repositories Customer entity var newCustomer = _mapper.Map <Customer>(customerPostDTO); // Apply audit changes to Customer entity newCustomer = Audit <Customer> .PerformAudit(newCustomer); // Insert new Customer into the respository newCustomer = await _customerRespository.Insert(newCustomer); // Map the Customer entity to DTO response object and return in body of response var customerResponseDTO = _mapper.Map <CustomerResponseDTO>(newCustomer); return(CreatedAtAction(nameof(CustomerGetById), new { customerResponseDTO.CustomerId }, customerResponseDTO)); }