예제 #1
0
 public IActionResult EditHotel(HotelViewModel model)
 {
     if (isEmployee())
     {
         ModelState.Remove("PhoneAdd");
         if (ModelState.IsValid)
         {
             Boolean insertResult = updateHotel(convertModelToHotel(model));
             if (insertResult)
             {
                 TempData["SuccessMessage"] = "Hotel updated";
                 return RedirectToAction("ManageHotels");
             }
             else
             {
                 ModelState.AddModelError(string.Empty, TempData["ErrorMessage"].ToString());
             }
         }
         // If we got this far, something failed, redisplay form
         model.initModel(_context, Convert.ToInt32(model.Hid));
         return View(model);
     }
     else
     {
         return RedirectToAction("AccessDenied", "Account");
     }
 }
예제 #2
0
 public IActionResult CreateHotel(HotelViewModel model, string returnUrl = null)
 {
     if (isEmployee())
     {
         ViewData["ReturnUrl"] = returnUrl;
         if (ModelState.IsValid)
         {
             Boolean insertResult = createHotel(model);
             if (insertResult)
             {
                 TempData["SuccessMessage"] = "Hotel created";
                 return RedirectToAction("ManageHotels");
             }
             else
             {
                 ModelState.AddModelError(string.Empty, TempData["ErrorMessage"].ToString());
             }
         }
         model.initModel(_context);
         // If we got this far, something failed, redisplay form
         return View(model);
     }
     else
     {
         return RedirectToAction("AccessDenied", "Account");
     }
 }