public async Task <IActionResult> CreateNewNote([FromBody] PreNote note) { try { var newNote = await _repository.CreateNewNoteAsync(new Note { Title = note.Title, Content = note.Content }); return(StatusCode(StatusCodes.Status201Created, newNote)); } catch (Exception exc) { return(StatusCode(StatusCodes.Status500InternalServerError, "Something has gone wrong")); } }
public async Task <IActionResult> EditNote([FromRoute] int id, [FromBody] PreNote note) { try { var newNote = await _repository.UpdateNoteAsync(id, note); return(Ok(newNote)); } catch (DataException exc) { return(BadRequest(exc.Message)); } catch (Exception exc) { return(StatusCode(StatusCodes.Status500InternalServerError, "Something has gone wrong")); } }