public ActionResult Add(AddDriverStopVM model) { using (TruckTransportDbContext _db = new TruckTransportDbContext()) { if (_db.stajalista.AsNoTracking().Where(x => x.naziv == model.Name || (x.sirina == model.Latitude && x.duzina == model.Longitude)).FirstOrDefault() != null) { ModelState.AddModelError("", "Stajalište sa unesenim nazivom ili pozicijom na karti već postoji!"); } if (ModelState.IsValid) { stajalista driverStopDB = new stajalista(); driverStopDB.naziv = model.Name; driverStopDB.opis = model.Description; driverStopDB.sirina = model.Latitude; driverStopDB.duzina = model.Longitude; _db.stajalista.Add(driverStopDB); _db.SaveChanges(); return(RedirectToAction(actionName: "Index")); } } return(View(viewName: "Add", model: model)); }
public ActionResult Add() { AddDriverStopVM model = new AddDriverStopVM(); return(View(viewName: "Add", model: model)); }