Example #1
0
 public IActionResult Create(Office model)
 {
     if (HttpContext.Session.GetString("ID") == null)
     {
         return(RedirectToAction("Login", "Admin"));
     }
     else
     {
         if (ModelState.IsValid)
         {
             bool check = officeRepository.checkID(model.ID);
             if (check)
             {
                 officeRepository.Add(model);
                 return(RedirectToAction("Index"));
             }
             else
             {
                 ViewBag.listAllCities = officeRepository.listAllCities();
                 ModelState.AddModelError(string.Empty, "This ID already exists.");
                 return(View());
             }
         }
         ViewBag.listAllCities = officeRepository.listAllCities();
         return(View(model));
     }
 }