Example #1
0
        public ActionResult Save(GlPost glPost)
        {
            if (glPost.GlAccountToCreditId == glPost.GlAccountToDebitId)
            {
                TempData["error"] = "You cannot Post to the same account";
                var glAccounts = _glAccountContext.GetAll();
                var viewModel  = new GlPostViewModel
                {
                    GlAccounts = glAccounts
                };
                return(View("GlPostForm", viewModel));
            }

            var postEntry = _context.PostEntry(glPost);

            if (postEntry == "Success")
            {
                glPost.PostedAt = DateTime.Now;
                glPost.UserId   = Convert.ToInt32(Session["id"]);
                _context.Save(glPost);
                TempData["success"] = "gl Posted Successfully";
            }
            else //if gl post fails,  Show error
            {
                TempData["error"] = postEntry;
                var glAccounts = _glAccountContext.GetAll();
                var viewModel  = new GlPostViewModel
                {
                    GlAccounts = glAccounts
                };
                return(View("GlPostForm", viewModel));
            }

            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult New()
        {
            var glAccounts = _glAccountContext.GetAll();
            var viewModel  = new GlPostViewModel
            {
                GlAccounts = glAccounts
            };

            return(View("GlPostForm", viewModel));
        }