public async Task <IActionResult> CreateNote([FromBody] Note note) { if (note == null) { return(NotFound()); } var item = new ItemCreatedResponse(); item.Id = await Manager.CreateNoteAsync(HttpContext, note); return(Created(string.Empty, item)); }
public async Task <IActionResult> CreateLabel([FromBody] Label label) { if (label == null) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (await Manager.LabelNameExistsAsync(HttpContext, label.Name)) { ModelState.AddModelError(nameof(label.Name), $"A label named '{label.Name}' already exists"); return(BadRequest(ModelState)); } var item = new ItemCreatedResponse(); item.Id = await Manager.CreateLabelAsync(HttpContext, label); return(Created(string.Empty, item)); }