// GET: Type/Delete/5 public bool Delete([FromBody] TipModel tip) { try { return(TipDAO.DeleteType(tip.AutoID)); } catch (Exception) { return(false); } }
public void CreateTypePopup([FromBody] TipModel tip) { try { tip.Marka.AutoID = tip.AutoID; TipDAO.CreateNewType(tip, HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik").Id); } catch (Exception e) { e.StackTrace.ToString(); } }
public async Task <object> Get(DataSourceLoadOptions loadOptions) { try { var tipovi = TipDAO.GetAllTypes(); object result = await Task.Run(() => DataSourceLoader.Load(tipovi, loadOptions)); return(result); } catch (Exception) { object result = await Task.Run(() => DataSourceLoader.Load(new List <TipModel>(), loadOptions)); return(result); } }
// GET: Type/Edit/5 public ActionResult Edit() { try { if (HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik") == null) { return(View("~/Views/Login/Index.cshtml")); } return(View(TipDAO.GetTypeById(Convert.ToInt32(HttpContext.Session.GetInt32("TipAutoID"))))); } catch (Exception) { return(View("Index")); } }
public void CreateBrandPopup([FromBody] MarkaModel marka) { try { marka.AutoID = MarkaDAO.CreateNewBrand(marka, HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik").Id); TipDAO.CreateNewType(new TipModel { Naziv = "-", Marka = marka }, HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik").Id); } catch (Exception e) { e.StackTrace.ToString(); } }
public ActionResult Create(TipModel tip) { try { if (HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik") == null) { return(View("~/Views/Login/Index.cshtml")); } TipDAO.CreateNewType(tip, HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik").Id); return(RedirectToAction(nameof(Index))); } catch { ViewBag.Message = "Unešeni tip već postoji!"; return(View()); } }
public ActionResult SaveEdit(TipModel tip) { try { if (HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik") == null) { return(View("~/Views/Login/Index.cshtml")); } tip.AutoID = Convert.ToInt32(HttpContext.Session.GetInt32("TipAutoID")); TipDAO.UpdateType(tip); return(RedirectToAction(nameof(Index))); } catch { return(View("Edit")); } }
public IActionResult RowInsert(string values) { try { var newBrand = new MarkaModel(); JsonConvert.PopulateObject(values, newBrand); newBrand.DatumZadnjeIzmjeneUTC = DateTime.Now; //if (!TryValidateModel(newBrand)) // return BadRequest(); newBrand.AutoID = MarkaDAO.CreateNewBrand(newBrand, HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik").Id); TipDAO.CreateNewType(new TipModel { Naziv = "-", Marka = newBrand }, HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik").Id); } catch (Exception) { } return(Ok()); }
public ActionResult Create(MarkaModel marka) { if (HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik") == null) { return(View("~/Views/Login/Index.cshtml")); } try { marka.AutoID = MarkaDAO.CreateNewBrand(marka, HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik").Id); TipDAO.CreateNewType(new TipModel { Naziv = "-", Marka = marka }, HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik").Id); return(RedirectToAction(nameof(Index))); } catch (Exception e) { ViewBag.Message = "Unešena marka već postoji!"; return(View()); } }