Exemple #1
0
        public ActionResult UpdateVolume([Bind(Exclude = "dateModified")] UsedProducts stock, string newVolume)
        {
            ////TODO : Add Validation to prevent negative values to be updated
            ViewBag.EmployeesID = new SelectList(db.Employees, "EmployeesID", "FullName", stock.EmployeesID);
            int s = int.Parse(newVolume);

            //if (!(newVolume == null))
            //{
            //    s= (int)newVolume;
            //}
            if (ModelState.IsValid)
            {
                if (s <= 0)
                {
                    return(Content("<script language='javascript' type='text/javascript'>alert('Couldnt update Volume as new Volume is 0 ! Go Back and try Agains!');</script>"));
                }
                else
                if (s > stock.Usedvolume)
                {
                    return(Content("<script language='javascript' type='text/javascript'>alert('Couldnt update Volume as new Volume is Greater than Current Volume ! Go Back and try Agains!');</script>"));
                }
                else
                {
                    stock.dateModified    = DateTime.Now;
                    stock.Usedvolume      = stock.Usedvolume - s;
                    db.Entry(stock).State = EntityState.Modified;

                    var newupdtmdl = new UpdateVolume();
                    newupdtmdl.dateUpdated    = DateTime.Now;
                    newupdtmdl.EmployeesID    = stock.EmployeesID;
                    newupdtmdl.newVolume      = s;
                    newupdtmdl.UsedProductsID = stock.UsedProductsID;
                    newupdtmdl.Employee       = db.Employees.Find(stock.EmployeesID);
                    newupdtmdl.UsedProducts   = db.UsedProducts.Find(stock.UsedProductsID);

                    db.UpdateVolume.Add(newupdtmdl);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(stock));
        }
 public IVolumeModel Any(UpdateVolume request)
 {
     return(workflow.Update(request));
 }