Exemple #1
0
        public ActionResult Create(BookingsViewModels model)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    AccountBook acct = new AccountBook()
                    {
                        Id         = Guid.NewGuid(),
                        Categoryyy = Convert.ToInt32(model.BookType),
                        Amounttt   = model.BookAmount,
                        Dateee     = model.BookDate,
                        Remarkkk   = model.BookMemo
                    };

                    AccountBookService.AddData(acct);
                    AccountBookService.Save();
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
 public ActionResult DeleteConfirmed(Guid id)
 {
     AccountBook.Models.AccountBook accountBook = _AccountBookSvc.GetSingle(id);
     _AccountBookSvc.Delete(accountBook);
     _AccountBookSvc.Save();
     return(RedirectToAction("Index"));
 }
Exemple #3
0
        public ActionResult Index([Bind(Include = "Id,Category,Amount,Date,Remark")] AccountBookViewModels accountBookViewModels)
        {
            //if (ModelState.IsValid)
            //{
            //accountBookModels.Id = Guid.NewGuid();
            //db.AccountBook.Add(accountBookModels);
            //db.SaveChanges();
            //return RedirectToAction("Index");
            //}

            //return View(accountBookModels);

            if (ModelState.IsValid)
            {
                accountBookViewModels.Id = Guid.NewGuid();
                _accountBookSvc.Add(accountBookViewModels);
                _accountBookSvc.Save();

                return(RedirectToAction("Index"));
            }

            var result = new AccountBookViewModels()
            {
                Id       = accountBookViewModels.Id,
                Amount   = accountBookViewModels.Amount,
                Category = accountBookViewModels.Category,
                Date     = accountBookViewModels.Date,
                Remark   = accountBookViewModels.Remark
            };

            return(View(result));
        }
Exemple #4
0
        public ActionResult Create(AccountingViewModel data)
        {
            if (ModelState.IsValid)
            {
                _accountBookService.Add(data);
                _accountBookService.Save();

                return(RedirectToAction("Index"));
            }

            return(PartialView(data));
        }
Exemple #5
0
 public ActionResult AjaxPost(CreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         model.AccountBookModel.ClassType = model.CategoryOptions.ToString();
         //fix null存檔會出錯
         model.AccountBookModel.Note = model.AccountBookModel.Note ?? string.Empty;
         _accountBookSvc.Add(model.AccountBookModel);
         _accountBookSvc.Save();
         return(RedirectToAction("ResultList"));
     }
     return(PartialView("CreatePartial", model));
 }
        public ActionResult Create([Bind(Include = "Id,Category,Amount,Date,Remark")] AccountBookViewModels accountBookViewModels)
        {
            if (ModelState.IsValid)
            {
                accountBookViewModels.Id = Guid.NewGuid();
                _accountBookSvc.Add(accountBookViewModels);
                _accountBookSvc.Save();

                return(RedirectToAction("Index"));
            }

            var result = new AccountBookViewModels()
            {
                Id       = accountBookViewModels.Id,
                Amount   = accountBookViewModels.Amount,
                Category = accountBookViewModels.Category,
                Date     = accountBookViewModels.Date,
                Remark   = accountBookViewModels.Remark
            };

            return(View(accountBookViewModels));
        }
Exemple #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());
        }
Exemple #8
0
        //[ValidateAntiForgeryToken]
        public ActionResult Create(MoneyModel moneyModel)
        {
            if (ModelState.IsValid)
            {
                var account = new AccountBook();
                account.Id         = Guid.NewGuid();
                account.Categoryyy = Convert.ToInt32(moneyModel.Type);
                account.Amounttt   = Convert.ToInt32(moneyModel.Money);
                account.Remarkkk   = moneyModel.Remark;
                _accountBookService.Add(account);
                _accountBookService.Save();

                return(RedirectToAction("AccountingBook"));
            }
            return(View(moneyModel));
        }