コード例 #1
0
        public InvoiceNoteDto Create(InvoiceNoteDto invoiceNote)
        {
            var insertedEntity = invoiceNoteRepository.Insert(
                invoiceNote.ToInvoiceNote(currentPrincipal.GetUserId()));

            invoiceNoteRepository.Save();

            return(insertedEntity.ToInvoiceNoteDto());
        }
コード例 #2
0
        public IActionResult Put(int invoiceId, InvoiceNoteDto invoiceNote)
        {
            if (invoiceId != invoiceNote?.InvoiceId)
            {
                throw new BadRequestException(ExceptionMessageKeys.BadRequest);
            }

            invoiceNoteService.Update(invoiceNote);
            return(NoContent());
        }
コード例 #3
0
        public IActionResult Post(int invoiceId, InvoiceNoteDto invoiceNote)
        {
            if (invoiceId != invoiceNote?.InvoiceId)
            {
                throw new BadRequestException(ExceptionMessageKeys.BadRequest);
            }

            var createdInvoiceNote = invoiceNoteService.Create(invoiceNote);

            return(Created(createdInvoiceNote.Id.ToString(), createdInvoiceNote));
        }
コード例 #4
0
 public static InvoiceNote ToInvoiceNote(this InvoiceNoteDto invoiceNoteDto, int userId)
 {
     return(invoiceNoteDto == null
         ? null
         : new InvoiceNote()
     {
         Id = invoiceNoteDto.Id,
         InvoiceId = invoiceNoteDto.InvoiceId,
         Text = invoiceNoteDto.Text,
         UserId = userId
     });
 }
コード例 #5
0
        public void Update(InvoiceNoteDto invoiceNote)
        {
            var userId = currentPrincipal.GetUserId();
            var entity = invoiceNoteRepository.GetById(invoiceNote.Id);

            if (userId != entity?.UserId)
            {
                throw new ForbiddenException();
            }

            invoiceNoteRepository.Update(invoiceNote.ToInvoiceNote(entity));
            invoiceNoteRepository.Save();
        }
コード例 #6
0
 public static InvoiceNote ToInvoiceNote(this InvoiceNoteDto invoiceNoteDto, InvoiceNote invoiceNote)
 {
     invoiceNote.Text = invoiceNoteDto.Text;
     return(invoiceNote);
 }