public InvoiceNoteDto Create(InvoiceNoteDto invoiceNote) { var insertedEntity = invoiceNoteRepository.Insert( invoiceNote.ToInvoiceNote(currentPrincipal.GetUserId())); invoiceNoteRepository.Save(); return(insertedEntity.ToInvoiceNoteDto()); }
public IActionResult Put(int invoiceId, InvoiceNoteDto invoiceNote) { if (invoiceId != invoiceNote?.InvoiceId) { throw new BadRequestException(ExceptionMessageKeys.BadRequest); } invoiceNoteService.Update(invoiceNote); return(NoContent()); }
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)); }
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 }); }
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(); }
public static InvoiceNote ToInvoiceNote(this InvoiceNoteDto invoiceNoteDto, InvoiceNote invoiceNote) { invoiceNote.Text = invoiceNoteDto.Text; return(invoiceNote); }