コード例 #1
0
        public IActionResult Create(NoteVM noteVM)
        {
            if (ModelState.IsValid)
            {
                Note newNote = noteVM.Note;

                if (noteVM.NoteTags != null)
                {
                    foreach (var t in _db.Tag)
                    {
                        if (noteVM.NoteTags.Contains(t.Id))
                        {
                            NoteTag noteTag = new NoteTag {
                                NotesId = newNote.Id, TagsId = t.Id
                            };
                            newNote.NoteTags.Add(noteTag);
                        }
                    }
                }
                _db.Note.Add(newNote);
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(noteVM));
        }
コード例 #2
0
 public IActionResult Create(Tag obj)
 {
     if (ModelState.IsValid)
     {
         _db.Tag.Add(obj);
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(obj));
 }
コード例 #3
0
 public IActionResult Create(Rem obj)
 {
     if (ModelState.IsValid)
     {
         Rem newRem = new Rem {
             EventDate = obj.EventDate, NoteId = obj.NoteId
         };
         _db.Rem.Add(newRem);
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(obj));
 }