public InvoiceDto Create(InvoiceDto invoice) { var insertedEntity = invoiceRepository.Insert( invoice.ToInvoice(currentPrincipal.GetUserId())); invoiceRepository.Save(); return(insertedEntity.ToInvoiceDto()); }
public void Update(InvoiceDto invoice) { var userId = currentPrincipal.GetUserId(); var entity = invoiceRepository.GetById(invoice.Id); if (userId != entity?.UserId) { throw new ForbiddenException(); } invoiceRepository.Update(invoice.ToInvoice(entity)); invoiceRepository.Save(); }