public ActionResult Edit(BatchNote batchnote) { if (ModelState.IsValid) { db.Entry(batchnote).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(batchnote); }
public static BatchNote createBatchNote(Batch batch, String title, String text, UserProfile user) { BrewersBuddyContext db = new BrewersBuddyContext(); BatchNote note = new BatchNote(); note.Batch = batch; note.Text = text; note.Title = title; note.AuthorId = user.UserId; note.AuthorDate = DateTime.Now; db.BatchNotes.Add(note); db.SaveChanges(); return note; }
public ActionResult EditNote(BatchNote note) { if (ModelState.IsValid) { BrewersBuddyContext db2 = new BrewersBuddyContext(); db2.Entry(note).State = EntityState.Modified; db2.SaveChanges(); //Associate the batch with the note int batchId = (int)Session["CurrentBatchId"]; return RedirectToAction("Details/" + batchId); } return View(note); }
public ActionResult AddNote(BatchNote note) { if (ModelState.IsValid) { //Add the date note.AuthorDate = DateTime.Now; note.AuthorId = ControllerUtils.getCurrentUserId(User); //Associate the batch with the action int batchId = (int)Session["CurrentBatchId"]; Batch batch = db.Batches.Find(batchId); db.Entry(note).State = EntityState.Added; batch.Notes.Add(note); db.SaveChanges(); return RedirectToAction("Details/" + batch.BatchId); } return View(note); }