예제 #1
0
        public async Task <IActionResult> PutNote([FromRoute] int id, [FromBody] Note note)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != note.ID)
            {
                return(BadRequest());
            }

            try
            {
                await _notesService.EditNote(note);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_notesService.NoteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public ActionResult <int> EditNote([FromBody] Notes note)
        {
            int result = _notesService.EditNote(note);

            if (result == 0)
            {
                return(BadRequest());
            }

            return(Ok(result));
        }
예제 #3
0
 public ActionResult UpdateNote(int id, [FromBody] NoteWithCategories note)
 {
     try
     {
         _service.EditNote(id, note);
         _service.DeleteDanglingCategories();
     }
     catch
     {
         return(BadRequest());
     }
     return(Ok());
 }
예제 #4
0
        public async Task <IActionResult> PutNote([FromRoute] int id, [FromBody] Note note)
        {
            await _notesService.EditNote(id, note);

            return(NoContent());
        }