예제 #1
0
 public ActionResult DeleteConfirmed(Guid id)
 {
     Models.AccountBook accountBook = _AccountBookSvc.GetSingle(id);
     _AccountBookSvc.Delete(accountBook);
     _AccountBookSvc.Save();
     return(RedirectToAction("Index"));
 }
예제 #2
0
 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;
 }
예제 #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));
 }
예제 #4
0
        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());
        }
예제 #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));
        }
예제 #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));
        }
예제 #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());
        }
예제 #8
0
 public void Delete(Models.AccountBook data)
 {
     _AccountBookRep.Remove(data);
 }
예제 #9
0
 public void Add(Models.AccountBook AccountBookList)
 {
     _AccountBookRep.Create(AccountBookList);
 }