public async Task <IActionResult> AddMessage(NoteAddDto messageAddDto) { var validationResult = await _noteAddDtoValidator.ValidateAsync(messageAddDto); if (!validationResult.IsValid) { return(BadRequest(new { errorMessage = "در اعتبارسنجی مشکلی پیش آمده است" })); } var token = HttpContext.GetAuthenticationToken(); var userJwtToken = await _jwtService.GetJwtTokenAsync(token); var messageGetDto = await _noteService.AddAsync(userJwtToken.UserId, messageAddDto); return(Ok(new { messageObj = messageGetDto, message = "پیام با موفقیت اضافه شد" })); }
public Note Add(Guid userId, NoteAddDto noteDto) { try { Note note = new Note { Id = Guid.NewGuid(), Title = noteDto.Title, Description = noteDto.Description, CreatedDate = DateTime.Now, DueDate = noteDto.DueDate, UserId = userId, ModifiedDate = null }; return(_noteRepository.Add(note)); } catch (Exception ex) { throw ex; } }
public Note Add(NoteAddDto model) { return(_noteService.Add(model)); }
public Note Add(NoteAddDto model) { Guid userId = _controllerUtilityService.GetAuthorizedUserId(User); return(_noteService.Add(userId, model)); }