コード例 #1
0
 public IActionResult AddNote(Note note)
 {
     if (ModelState.IsValid)
     {
         _noteService.AddNote(note);
         return(RedirectToAction(nameof(List)));
     }
     return(View());
 }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
 public IActionResult AddNote(Note note)
 {
     _noteServices.AddNote(note);
     return(CreatedAtRoute("GetNote", new { id = note.Id }, note));
 }