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