public bool Delete([FromBody] ProizvodjacModel proizvodjac) { try { return(ProizvodjacDAO.DeleteManufacturer(proizvodjac.AutoID)); } catch (Exception) { return(false); } }
public void CreateManufacturerPopup([FromBody] ProizvodjacModel proizvodjac) { try { ProizvodjacDAO.CreateNewManufacturer(proizvodjac, HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik").Id); } catch (Exception e) { e.StackTrace.ToString(); } }
public object Get(DataSourceLoadOptions loadOptions) { try { var proizvodjaci = ProizvodjacDAO.GetAllManufacturers(); return(DataSourceLoader.Load(proizvodjaci, loadOptions)); } catch (Exception) { return(DataSourceLoader.Load(new List <ProizvodjacModel>(), loadOptions)); } }
public object GetDetail(DataSourceLoadOptions loadOptions) { try { var proizvodjaci = ProizvodjacDAO.GetAllManufacturers(); foreach (var item in proizvodjaci) { item.Naziv = item.Naziv + ", " + item.Adresa; } return(DataSourceLoader.Load(proizvodjaci, loadOptions)); } catch (Exception) { return(DataSourceLoader.Load(new List <ProizvodjacModel>(), loadOptions)); } }
// GET: Manufacturer/Edit/5 public ActionResult Edit() { try { if (HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik") == null) { return(View("~/Views/Login/Index.cshtml")); } return(View(ProizvodjacDAO.GetManufacturerById(Convert.ToInt32(HttpContext.Session.GetInt32("ProizvodjacAutoID"))))); } catch (Exception) { return(View("Index")); } }
public ActionResult SaveEdit(ProizvodjacModel proizvodjac) { try { if (HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik") == null) { return(View("~/Views/Login/Index.cshtml")); } proizvodjac.AutoID = Convert.ToInt32(HttpContext.Session.GetInt32("ProizvodjacAutoID")); ProizvodjacDAO.UpdateManufacturer(proizvodjac); return(RedirectToAction(nameof(Index))); } catch { return(View("Edit")); } }
public ActionResult Create(ProizvodjacModel proizvodjac) { try { if (HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik") == null) { return(View("~/Views/Login/Index.cshtml")); } ProizvodjacDAO.CreateNewManufacturer(proizvodjac, HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik").Id); return(RedirectToAction(nameof(Index))); } catch (Exception e) { ViewBag.Message = "Unešeni proizvođač već postoji!"; return(View()); } }