Exemple #1
0
        public InvoiceDto Create(InvoiceDto invoice)
        {
            var insertedEntity = invoiceRepository.Insert(
                invoice.ToInvoice(currentPrincipal.GetUserId()));

            invoiceRepository.Save();

            return(insertedEntity.ToInvoiceDto());
        }
Exemple #2
0
        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();
        }