public IActionResult AddNote(Note note) { if (ModelState.IsValid) { _noteService.AddNote(note); return(RedirectToAction(nameof(List))); } return(View()); }
public ActionResult Post([FromQuery] int userId, [FromBody] NoteDTOM note) { try { var user = _userService.GetUserById(userId); note.UserId = userId; _noteService.AddNote(note); return(Ok("Note successfully created")); } catch (NoteException ex) { return(BadRequest(ex.Message)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public IActionResult AddNote(Note note) { _noteServices.AddNote(note); return(CreatedAtRoute("GetNote", new { id = note.Id }, note)); }