public async Task <ActionResult <CustomerItem> > Post([FromBody] CustomerItem value) { try { if (value == null) //TODO: add validators { return(new BadRequestResult()); } var newCustomer = _customerMapper.Map(value); await _customerRepository.AddAsync(newCustomer); return(new OkObjectResult(newCustomer.Id)); } catch (Exception e) //TODO middleware { return(_service.Catch(e)); } }
public async Task <ActionResult <InvoiceItem> > Post([FromBody] InvoiceItem value) { try { if (value == null) //TODO: add validators { return(new BadRequestResult()); } var newInvoice = _invoiceMapper.Map(value); var updatedInvoice = await _invoiceRepository.AddAsync(newInvoice); var createdInvoiceItem = _invoiceItemMapper.Map(updatedInvoice); return(new OkObjectResult(createdInvoiceItem)); } catch (Exception e) //TODO middleware { return(_errorService.Catch(e)); } }