public ActionResult Edit(RestaurantInput input)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("Create", input));
            }

            var rest = Db.Get <Restaurant>(Convert.ToInt32(input.Id));

            rest.Name = input.Name;

            return(Json(new { rest.Id }));
        }
        public ActionResult Create(RestaurantInput input)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(input));
            }

            var restaurant = Db.Get <Restaurant>(input.Id);

            restaurant.Name      = input.Name;
            restaurant.IsCreated = true;

            return(Json(restaurant)); // use MapToGridModel like in Grid Crud Demo when grid uses Map
        }
Пример #3
0
        public ActionResult Edit(RestaurantInput input)
        {
            if (!ModelState.IsValid)
            {
                return(Json(ModelState.GetErrorsInline()));
            }

            var ent = Db.Get <Restaurant>(input.Id);

            ent.Name = input.Name;
            Db.Update(ent);

            return(Json(new { }));
        }
Пример #4
0
        public ActionResult Create(RestaurantInput input)
        {
            if (!ModelState.IsValid)
            {
                return(Json(ModelState.GetErrorsInline()));
            }

            var ent = Db.Insert(new Restaurant
            {
                Name      = input.Name,
                IsCreated = true
            });

            return(Json(new { Item = MapToGridModel(ent) }));
        }
Пример #5
0
 public IActionResult RestaurantInput(RestaurantInput restaurantInput)
 {
     //verifies that the form has been filled correctly
     if (ModelState.IsValid)
     {
         TempStorage.AddRestaurant(restaurantInput);
         //if fav dish is null then display its all tasty
         foreach (RestaurantInput ri in TempStorage.restaurantInputs)
         {
             if (ri.FavoriteDish == null | ri.FavoriteDish == "")
             {
                 ri.FavoriteDish = "It's all tasty!";
             }
         }
         //if correct then it displays the inputted restaurants
         return(View("RestaurantList", TempStorage.restaurantInputs));
     }
     else
     {
         //if not filled correctly then it will stay on the RestaurantInput page and display the error (incorrect phone format)
         return(View());
     }
 }