public int AddTown(TownModel townModel)
 {
     try
     {
         return(townRepository.AddTown(townModel));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public ActionResult Create(Town town)
        {
            if (!IsTownNameValid(town.TownName))
            {
                return(RedirectToAction("Index"));
            }

            if (ModelState.IsValid)
            {
                townRepository.AddTown(town);
                townRepository.Save();
                TempData["message"] = String.Format("Grad {0} je uspešno dodat u evidenciju!", town.TownName);

                return(RedirectToAction("Index"));
            }

            return(View("Index", town));
        }