Example #1
0
        // GET: Restaurant/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            if (Session["roleId"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (Session["roleId"].ToString() != "1")
            {
                return(RedirectToAction("Index", "Home"));
            }

            var categories = new List <RestaurantCategory>();

            categories.Add(new RestaurantCategory {
                Id = 0, Name = "-No Category-"
            });
            categories.AddRange(await _proxy.GetAllRestaurantCategoriesAsync());

            var model = new RestaurantViewModel {
                Restaurant = await _proxy.GetRestaurantAsync(id), CategoryList = new SelectList(categories, "Id", "Name", 1)
            };

            return(View("Edit", model));
        }