public void RemoveNote(ApplicationDbContext context, NoteModelDto note) { //TODO: this should not return void context.Notes.Attach(note); context.Notes.Remove(note); context.SaveChanges(); }
public IActionResult Submit(NoteModelDto model) { model.Date = DateTime.Now; if (!ModelState.IsValid) { //TODO: create error handler for this case return(RedirectToAction("NoteNotFound", new { id = model.Id })); } //TODO: try except _service.CreateNote(_context, model); return(RedirectToAction("List")); }
public void CreateNote(ApplicationDbContext context, NoteModelDto note) { context.Notes.Add(note); context.SaveChanges(); }