/// <summary> /// This function searches a candy by its name /// </summary> public ActionResult SearchCandies() { CandyDal dal = new CandyDal(); string searchValue = Request.Form["CandyName"]; List <Candy> objCandies; if (searchValue != null && searchValue.Equals("")) { objCandies = (from x in dal.Candies where x.CandyName.Contains(" ") select x).ToList <Candy>(); } else { objCandies = (from x in dal.Candies where x.CandyName.Contains(searchValue) select x).ToList <Candy>(); } CandyVM cvm = new CandyVM(); cvm.Candy = new Candy(); cvm.Candies = objCandies; return(View("SearchCandies", cvm)); }
/// <summary> /// This function searches a candy by its name /// </summary> public ActionResult SearchCandies() { if (Session["Manager"] == null) { TempData["Result"] = true; return(RedirectToAction("", "")); } CandyDal dal = new CandyDal(); string searchValue = Request.Form["CandyName"]; List <Candy> objCandies; if (searchValue != null && searchValue.Equals("")) { objCandies = (from x in dal.Candies where x.CandyName.Contains(" ") select x).ToList <Candy>(); } else { objCandies = (from x in dal.Candies where x.CandyName.Contains(searchValue) select x).ToList <Candy>(); } CandyVM cvm = new CandyVM(); cvm.Candy = new Candy(); cvm.Candies = objCandies; return(View("SearchCandies", cvm)); }
/// <summary> /// This function shows the inventory of the candies /// </summary> /// <returns>the DisplayCandies view</returns> public ActionResult CandyInventory() { CandyVM cvm = new CandyVM(); cvm.Candy = new Candy(); CandyDal dal = new CandyDal(); cvm.Candies = new List <Candy>(); cvm.Candies = dal.Candies.ToList <Candy>(); return(View("CandyInventory", cvm)); }
/// <summary> /// This function opens a coonection to the database and calls the NewCandy view /// </summary> public ActionResult NewCandy() { if (Session["Manager"] == null) { TempData["Result"] = true; return(RedirectToAction("", "")); } CandyDal dal = new CandyDal(); CandyVM cvm = new CandyVM(); cvm.Candy = new Candy(); cvm.Candies = dal.Candies.ToList <Candy>(); return(View(cvm)); }