コード例 #1
0
 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());
     }
 }
コード例 #2
0
 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());
     }
 }
コード例 #3
0
 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());
     }
 }