Пример #1
0
        public ActionResult Edit(LedgerEntry entry, bool add = false)
        {
            EFLedgerEntries ledgerEntries = new EFLedgerEntries();

            if (ModelState.IsValid)
            {
                if (!add)
                    ledgerEntries.Edit(entry);
                else
                    ledgerEntries.Add(entry);

                return RedirectToAction("List");
            }
            else
            {
                ViewBag.Add = add;
                return View();
            }
        }
Пример #2
0
        public ViewResult Edit(int entryID)
        {
            LedgerEntry entry = new LedgerEntry();
            if (entryID == -1)
            {
                ViewBag.Add = true;
            }
            else
            {
                IQueryable<LedgerEntry> list = Entries.GetEntries;

                entry = list.Select(e => e)
                .Where(e => e.LedgerEntryID == entryID)
                .First();
            }

            return View( entryID < 1 ?
                new LedgerEntry() :
                entry);
        }
Пример #3
0
 public void Delete(LedgerEntry entry)
 {
     dBContext.Entry(entry).State = System.Data.EntityState.Deleted;
     dBContext.SaveChanges();
 }
Пример #4
0
 public void Edit(LedgerEntry entry)
 {
     dBContext.Entry(entry).State = System.Data.EntityState.Modified;
     dBContext.SaveChanges();
 }
Пример #5
0
 public void Add(LedgerEntry entry)
 {
     entry.Time = DateTime.Now;
     dBContext.Entry(entry).State = System.Data.EntityState.Added;
     dBContext.SaveChanges();
 }