private async Task AddNoteAsync() { var account = await _accountService.GetAsync(Session.Id); await _noteService.AddAsync(NoteForm, account); await ResetNoteFormAsync(); }
public async Task <ActionResult> Post([FromBody] NoteAdd value) { var result = await _noteService.AddAsync(value); if (result.IsError) { result.StatuCode = 400; return(BadRequest(result)); } return(Ok(result)); }
public async Task <IActionResult> Index(CreateNoteCommand command) { try { await _noteService.AddAsync(command); return(RedirectToAction("List", "Home")); } catch (InternalSystemException ex) { return(View()); } }
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 async Task Create_Note_Success() { var userId = _context.Users.First().UserId; var note = new NoteModel { Text = "Какой то текст" }; //act var resultId = await _service.AddAsync(note, userId); var resultNote = await _context.Notes.SingleOrDefaultAsync(x => x.NoteId == resultId); //assert Assert.AreEqual(note.Text, resultNote.Text); }
public async Task <IActionResult> AddNote(AddNoteViewModel model) { if (!this.ModelState.IsValid) { return(View(nameof(AddNote), model)); } try { await _notesService.AddAsync(model.Note.EntityId, model.Note.NoteUser.Id, model.Note.Text, model.SelectedCategoryId, model.Note.HasStatus); return(RedirectToAction(nameof(Notes), new { entityId = model.Note.EntityId })); } catch (ArgumentException ex) { model.ErrorMessage = ex.Message; return(View(nameof(AddNote), model)); } }
public async Task <object> AddNote([FromBody] NoteModel mod, Guid idMaster) { var resultId = await _noteService.AddAsync(mod, idMaster); return(resultId); }