Ejemplo n.º 1
0
 public ActionResult Edit(BatchNote batchnote)
 {
     if (ModelState.IsValid)
     {
         db.Entry(batchnote).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(batchnote);
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }