Esempio n. 1
0
        public ActionResult FoodItemAdd(FormCollection fc, HttpPostedFileBase fileHotDealImage,HttpPostedFileBase fileFoodItemImage)
        {
            FoodItem f1 = new FoodItem();

            f1.FoodItemName = fc["txtFoodItemName"];
            f1.RestaurantId = Convert.ToInt32(fc["hddRestaurantId"]);
            f1.FoodCategoryId = Convert.ToInt32(fc["hddFoodCategoryId"]);
            f1.FoodDescription = fc["txtFoodDescription"];
            f1.FoodItemRate = Convert.ToDouble(fc["txtFoodItemRate"]);
            if (fileFoodItemImage != null)
            {
                string fileName = checkfile(fileFoodItemImage.FileName);
                string filePath = Path.Combine(Server.MapPath("~/images/Uploads"), Path.GetFileName(fileName));
                fileFoodItemImage.SaveAs(filePath);
                f1.FoodItemImage = fileName;
            }
            String hotDeals =  fc["chkHotDeals"];

            if (hotDeals == "on")
            {
                f1.IsHotDeal = true;
                f1.HotDealDescription = fc["txtHotDealDescription"];
                if (fileHotDealImage != null)
                {
                    string fileName = checkfile(fileHotDealImage.FileName);
                    string filePath = Path.Combine(Server.MapPath("~/images/HotDeals"), Path.GetFileName(fileName));
                    fileHotDealImage.SaveAs(filePath);
                    f1.HotDealImage = fileName;
                }

            }
            db.FoodItems.Add(f1);
            db.SaveChanges();

            return RedirectToAction("FoodItemList", new { id = f1.FoodCategoryId });
        }
Esempio n. 2
0
        public ActionResult FoodAdd(FormCollection fc, HttpPostedFileBase fileFoodItem)
        {
            int restaurantId = Convert.ToInt32(fc["hddRestaurantId"]);
            FoodItem f1 = new FoodItem();
            RestaurantFoodCategory rfcate = new RestaurantFoodCategory();
            rfcate.FoodCategoryId = Convert.ToInt32(fc["ddlFoodCategory"]);
            rfcate.RestaurantId = Convert.ToInt32(fc["hddRestaurantId"]); ;
            db.RestaurantFoodCategories.Add(rfcate);
            db.SaveChanges();
            f1.FoodItemName = fc["txtFoodItemName"];
            f1.FoodDescription = fc["txtDesc"];
            f1.RestaurantId = Convert.ToInt32(fc["hddRestaurantId"]);
            f1.FoodCategoryId = Convert.ToInt32(fc["ddlFoodCategory"]);
            f1.FoodItemRate = Convert.ToDouble(fc["txtRate"]);
            if (fileFoodItem != null)
            {
                string fileName = checkfile(fileFoodItem.FileName);
                string filePath = Path.Combine(Server.MapPath("~/Uploads"), Path.GetFileName(fileName));
                fileFoodItem.SaveAs(filePath);
                f1.FoodItemImage = fileName;

            }
            db.FoodItems.Add(f1);
            db.SaveChanges();

            return RedirectToAction("Foodmenu", new { id = restaurantId});
        }