public ActionResult Add(TownDTO entity) { try { Town t = new Town(); t.Name = entity.Name; t.CityID = entity.CityID; townRepository.Add(t); townRepository.Save(); return(Json(entity, JsonRequestBehavior.DenyGet)); } catch (Exception e) { return(Json(false, JsonRequestBehavior.DenyGet)); } }
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)); }