Пример #1
0
 public IActionResult CreateConvenient(Convenients model)
 {
     if (HttpContext.Session.GetString("ID") == null)
     {
         return(RedirectToAction("Login", "Admin"));
     }
     else
     {
         //check validation
         if (ModelState.IsValid)
         {
             //check duplicate
             bool check = hotelRepository.checkConvenientID(model.ID);
             if (check)
             {
                 hotelRepository.AddConvenient(model);
                 return(RedirectToAction("Index"));
             }
             else
             {
                 ModelState.AddModelError(string.Empty, "This ID already exists.");
                 return(View());
             }
         }
         return(View(model));
     }
 }