Ejemplo n.º 1
0
        public ActionResult Edit(Town town)
        {
            if (!IsTownNameValid(town.TownName))
            {
                return RedirectToAction("Index");
            }

            if (ModelState.IsValid)
            {
                townRepository.UpdateTown(town);
                townRepository.Save();

                return RedirectToAction("Index");
            }

            return View(town);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public void UpdateTown(Town town)
 {
     db.Entry(town).State = System.Data.Entity.EntityState.Modified;
 }
Ejemplo n.º 4
0
 public void AddTown(Town town)
 {
     db.Towns.Add(town);
 }