public ActionResult Create(BatchAction batchAction)
        {
            if (ModelState.IsValid)
            {
                batchAction.PerformerId = ControllerUtils.getCurrentUserId(User);
                db.BatchActions.Add(batchAction);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(batchAction);
        }
Beispiel #2
0
        public void TestAddBatchAction()
        {
            Batch batch = new Batch();
            batch.Name = "Test";
            batch.Type = BatchType.Beer;
            batch.StartDate = DateTime.Now;

            context.Batches.Add(batch);

            BatchAction action = new BatchAction();
            action.Batch = batch;
            action.Description = "99 bottles of beer on the wall!";
            action.Type = ActionType.Bottle;
            action.Title = "Bottles the beer";
            action.ActionDate = DateTime.Now;

            context.BatchActions.Add(action);
            context.SaveChanges();

            Assert.IsTrue(batch.Actions.Contains(action));
        }
        public ActionResult AddAction(BatchAction action)
        {
            SelectActionType();
            if (ModelState.IsValid)
            {
                //Add the date
                action.ActionDate = DateTime.Now;
                action.PerformerId = ControllerUtils.getCurrentUserId(User);

                //Associate the batch with the action
                int batchId = (int)Session["CurrentBatchId"];
                Batch batch = db.Batches.Find(batchId);

                db.Entry(action).State = EntityState.Added;
                batch.Actions.Add(action);

                db.SaveChanges();
                return RedirectToAction("Details/" + batch.BatchId);
            }
            return View(action);
        }
 public ActionResult Edit(BatchAction batchAction)
 {
     if (ModelState.IsValid)
     {
         db.Entry(batchAction).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(batchAction);
 }