Exemple #1
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));
        }
Exemple #2
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());
        }