Example #1
0
        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"));
 }
Example #3
0
 public void CreateNote(ApplicationDbContext context, NoteModelDto note)
 {
     context.Notes.Add(note);
     context.SaveChanges();
 }