예제 #1
0
        public IActionResult Create(mtBank item)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            string   user   = HttpContext.Session.GetString("fullname");
            DateTime txDate = DateTime.Now;

            item.createdBy = user;
            item.createdOn = txDate;
            item.updatedBy = user;
            item.updatedOn = txDate;

            if (ModelState.IsValid)
            {
                mContext.mtBank.Add(item);
                mContext.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "Bank").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ViewBag.Error = true;
            return(View("Create"));
        }
예제 #2
0
        public IActionResult IsActive(int id)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            mtBank item = mContext.mtBank.Find(id);

            item.isActive = !item.isActive;

            string   user   = HttpContext.Session.GetString("fullname");
            DateTime txDate = DateTime.Now;

            item.updatedBy = user;
            item.updatedOn = txDate;

            mContext.Entry(item).State = EntityState.Modified;
            mContext.SaveChanges();

            return(RedirectToAction("Index"));
        }