public ActionResult Create(DokumentFakture dokument) { // TODO: Add insert logic here try { using (LocalDBEntities dBEntity = new LocalDBEntities()) { dBEntity.DokumentFaktures.Add(dokument); dBEntity.SaveChanges(); } return(RedirectToAction("Index")); } catch { System.Windows.Forms.MessageBox.Show("Faktura nije dodata!"); return(View()); } }
public ActionResult Edit(int id, DokumentFakture dokument) { try { // TODO: Add update logic here using (LocalDBEntities dbEntity = new LocalDBEntities()) { string idStr = id.ToString(); dbEntity.Entry(dokument).State = System.Data.EntityState.Modified; dbEntity.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(string id, FormCollection collection) { try { // TODO: Add delete logic here using (LocalDBEntities dbEntity = new LocalDBEntities()) { DokumentFakture dokument = dbEntity.DokumentFaktures.Where(x => x.RedniBroj == id).FirstOrDefault(); dbEntity.DokumentFaktures.Remove(dokument); dbEntity.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }