Beispiel #1
0
        public IActionResult Create(mtContainer 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.mtContainer.Add(item);
                mContext.SaveChanges();

                return(RedirectToAction("Index"));
            }

            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            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 == "Container").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"));
        }
Beispiel #2
0
        public IActionResult IsActive(int id)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            mtContainer container = mContext.mtContainer.Find(id);

            container.isActive = !container.isActive;

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

            container.updatedBy = user;
            container.updatedOn = txDate;

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

            return(RedirectToAction("Index"));
        }