Beispiel #1
0
        public IActionResult OnPost()
        {
            // Because ASP.Net core is stateless so OnPost() request Cuisines Enum will be lost
            // as populated by OnGet()
            Cuisines = htmlHelper.GetEnumSelectList <CuisineType>();

            if (ModelState.IsValid)                // Validating Data Annotations using IsValid Property
            {                                      // if any validation error occurs then it is saved in
                                                   // ModelState["Location"].Errors collection (for Restaurant.Location field only)
                RestaurantData.Update(Restaurant); // Yha pr restaurant avail kese hua
                RestaurantData.commit();
                // As post must redirect to some Get req page so the changes might not
                // get submitted again if user refreshes the page
                return(RedirectToPage("./RestaurantDetails", new { RestaurantId = Restaurant.id }));
            }

            return(Page());
        }