public ActionResult EditItem(EditItemViewModel eivm)
        {
            if (Session["User"] == null)
            {
                return RedirectToAction("LoginPage", "Application");
            }
            else if (!Session["Elevation"].Equals("Administrator"))
            {
                return RedirectToAction("LoggedInProfile");
            }
            else
            {
                Item i = db.Items.Find(eivm.id);
                if(i == null)
                {
                    this.ModelState.AddModelError("id", "General Error");
                }
                if (ModelState.IsValid) // checks required in model. does server validation
                {
                    i.name = eivm.name;
                    i.description = eivm.description;
                    i.price = eivm.price;
                    UploadImage(eivm.image, eivm.name + ".png");
                    db.SaveChanges();

                    return RedirectToAction("Store", "Application");
                }
                else
                {
                    return RedirectToAction("Store", "Application");
                }
            }
        }
 private EditItemViewModel GetEditItemViewModel(Item i)
 {
     EditItemViewModel eivm = new EditItemViewModel();
     eivm.id = i.id;
     eivm.name = i.name;
     eivm.price = i.price;
     eivm.description = i.description;
     eivm.orig_image = GetImageURL(eivm.name + ".png");
     return eivm;
 }