Esempio n. 1
0
 public ActionResult DeleteConfirmed(Guid id)
 {
     Models.AccountBook accountBook = _AccountBookSvc.GetSingle(id);
     _AccountBookSvc.Delete(accountBook);
     _AccountBookSvc.Save();
     return(RedirectToAction("Index"));
 }
 public void Edit(Models.AccountBook pageData, Models.AccountBook oldData)
 {
     oldData.Date     = pageData.Date;
     oldData.Category = pageData.Category;
     oldData.Amount   = pageData.Amount;
     oldData.Remark   = pageData.Remark;
 }
Esempio n. 3
0
 public ActionResult Delete(Guid?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Models.AccountBook accountBook = _AccountBookSvc.GetSingle(id.Value, User.Identity.Name);
     if (accountBook == null)
     {
         return(HttpNotFound());
     }
     return(View(accountBook));
 }
        public ActionResult Index(ViewModels.Home.AccountingViewModel pageData)
        {
            if (!ModelState.IsValid)
            {
                return(View(pageData));
            }

            var item = new Models.AccountBook()
            {
                Id       = Guid.NewGuid(),
                Category = (int)pageData.Category,
                Date     = pageData.Date,
                Amount   = pageData.Money,
                Remark   = pageData.Description
            };

            this.db.AccountBook.Add(item);
            this.db.SaveChanges();

            return(View());
        }
Esempio n. 5
0
        public ActionResult Edit([Bind(Include = "Id,Category,Amount,Date,Remark")] Models.ViewModels.EditRecordViewModel accountBook)
        {
            var oldData = _AccountBookSvc.GetSingle(accountBook.Id);

            if (oldData != null && ModelState.IsValid)
            {
                var theRecord = new Models.AccountBook
                {
                    Id       = accountBook.Id,
                    Category = (int)accountBook.Category,
                    Date     = accountBook.Date,
                    Amount   = accountBook.Amount,
                    Remark   = accountBook.Remark
                };

                _AccountBookSvc.Edit(theRecord, oldData);
                _AccountBookSvc.Save();
                return(RedirectToAction("Index"));
            }
            return(View(accountBook));
        }
Esempio n. 6
0
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Models.AccountBook accountBook = _AccountBookSvc.GetSingle(id.Value, User.Identity.Name);
            if (accountBook == null)
            {
                return(HttpNotFound());
            }

            var result = new EditRecordViewModel
            {
                Id       = accountBook.Id,
                Date     = accountBook.Date,
                Category = (BookType)accountBook.Category,
                Remark   = accountBook.Remark,
                Amount   = accountBook.Amount
            };

            return(View(result));
        }
Esempio n. 7
0
        public ActionResult Index([Bind(Include = "Category,Amount,Date,Remark")] Models.ViewModels.EditRecordViewModel accountBook)
        {
            if (ModelState.IsValid)
            {
                var CreatorID = User.Identity.Name;
                var recordId  = Guid.NewGuid();
                var NewRecord = new Models.AccountBook
                {
                    Id       = recordId,
                    Category = (int)accountBook.Category,
                    Date     = accountBook.Date,
                    Amount   = accountBook.Amount,
                    Remark   = accountBook.Remark,
                    CreateDT = DateTime.Now,
                    Creator  = CreatorID
                };

                _AccountBookSvc.Add(NewRecord);
                _AccountBookSvc.Save();
            }

            return(View());
        }
 public void Delete(Models.AccountBook data)
 {
     _AccountBookRep.Remove(data);
 }
 public void Add(Models.AccountBook AccountBookList)
 {
     _AccountBookRep.Create(AccountBookList);
 }