public async Task <OrganizationNoteDto> AddAsync(OrganizationNoteSpecDto item, Guid creatorId) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (creatorId == default) { throw new ArgumentNullException(nameof(creatorId)); } var creator = await _usersRepository.GetByIdAsync(creatorId).ConfigureAwait(false); OrganizationNoteDto newNote = new OrganizationNoteDto { Text = item.Text, OrganizationId = item.OrganizationId, CreatorName = creator.Name, UserId = creatorId, }; return(await base.AddAsync <OrganizationNoteDto>(newNote) .ConfigureAwait(false)); }
public async Task <ActionResult <Guid> > CreateNote(OrganizationNoteSpecDto dto) { var userId = HttpContext.User.Claims.First(x => x.Type == JwtRegisteredClaimNames.Jti).Value; var newNote = await _organizationNotesService .AddAsync(dto, new Guid(userId)) .ConfigureAwait(false); if (!_organizationNotesService.ValidationDictionary.IsValid()) { return(BadRequest(new { errors = _organizationNotesService.ValidationDictionary.GetErrorMessages() })); } return(Ok(newNote.Id)); }