public ActionResult Add(AddOrderConditionVM model) { using (TruckTransportDbContext _db = new TruckTransportDbContext()) { if (_db.stanja.AsNoTracking().Where(x => x.opis == model.Description).FirstOrDefault() != null) { ModelState.AddModelError("", "Opis stanja naloga već postoji!"); } if (ModelState.IsValid) { stanja newOrderConditionDB = new stanja { opis = model.Description }; _db.stanja.Add(newOrderConditionDB); _db.SaveChanges(); return(Json(data: new { success = true })); } } return(PartialView(viewName: "_Add", model: model)); }
public ActionResult Add() { AddOrderConditionVM model = new AddOrderConditionVM(); return(PartialView(viewName: "_Add", model: model)); }