Exemple #1
0
        public ActionResult Save(FormCollection form, Guid?id)
        {
            ViewBag.Category = KeepAccountsAPI.GetKeepAccountType();

            Dictionary <string, string> errorMsg = KeepAccountsAPI.DataCheck(form);

            ViewBag.ErrorDic = errorMsg;

            if (errorMsg.Any())
            {
                return(View("Index"));
            }

            if (id.HasValue)
            {
                if (!KeepAccountsAPI.Edit(form, id))
                {
                    errorMsg.Add("EditFail", "編輯失敗!");
                    return(View("Index"));
                }
            }
            else
            {
                if (!KeepAccountsAPI.Create(form))
                {
                    errorMsg.Add("CreateFail", "新增失敗!");
                    return(View("Index"));
                }
            }

            return(RedirectToAction("Index"));
        }
Exemple #2
0
        // GET: KeepAccounts
        public ActionResult Index(Guid?id)
        {
            ViewBag.Category = KeepAccountsAPI.GetKeepAccountType();

            var model = id.HasValue ? _model1.AccountBooks.Find(id) : null;

            if (model != null)
            {
                _model1.Entry(model).Reload();//要加這行才不會讀到快取的舊資料
            }
            return(View(model));
        }
Exemple #3
0
        public ActionResult Delete(Guid id)
        {
            Dictionary <string, string> errorMsg = new Dictionary <string, string>();;

            ViewBag.ErrorDic = errorMsg;

            if (!KeepAccountsAPI.Delete(id))
            {
                errorMsg.Add("DeleteFail", "刪除失敗!");
                return(View("Index"));
            }

            return(RedirectToAction("Index"));
        }
Exemple #4
0
 public ActionResult List()
 {
     return(PartialView(KeepAccountsAPI.GetData()));
 }