예제 #1
0
        public ActionResult OnPost(string RestaurantName, List <int> FoodType, List <int> When)
        {
            try
            {
                if (ModelState.IsValid == false)
                {
                    return(Page());
                }
                string cs           = _config.GetConnectionString("Default");
                int    RestaurantID = fd.AddRestaurant(cs, RestaurantName);

                foreach (var item in FoodType)
                {
                    fd.AddRestaurantFoodType(cs, RestaurantID, Convert.ToInt32(item));
                }
                foreach (var item in When)
                {
                    fd.AddRestaurantWhen(cs, RestaurantID, Convert.ToInt32(item));
                }

                JsonResult result = null;
                result = new JsonResult(RestaurantID);
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }