Ejemplo n.º 1
0
        public IActionResult Index(Login loginInfo)
        {
            if (ModelState.IsValid)
            {
                Account loginAccountInfo = _iAccountManager.GetAll()
                                           .Where(a => a.Username == loginInfo.Username &&
                                                  a.Password == loginInfo.Password && a.Status == true)
                                           .FirstOrDefault();

                if (loginAccountInfo == null)
                {
                    ViewBag.ErrorMessage = "Invalid Username and Password! Try again.";
                    return(View());
                }

                Role        checkRole           = _iRoleManager.GetAll().Where(r => r.Id == 1).FirstOrDefault();
                RoleAccount checkRoleAndAccount = _iRoleAccountManager.GetAll()
                                                  .Where(cra => cra.RoleId == checkRole.Id &&
                                                         cra.AccountId == loginAccountInfo.Id && cra.Status == true)
                                                  .FirstOrDefault();

                if (checkRoleAndAccount != null)
                {
                    HttpContext.Session.SetString("AdminId", loginAccountInfo.Id.ToString());
                    return(RedirectToAction("Index", "Dashboard"));
                }
                else
                {
                    ViewBag.ErrorMessage = "Invalid Username and Password! Try again.";
                    return(View());
                }
            }
            return(View(loginInfo));
        }
Ejemplo n.º 2
0
        public IActionResult Index()
        {
            if (HttpContext.Session.GetString("AdminId") != null)
            {
                ICollection <RoleAccount> customerList = _iRoleAccountManager.GetAll()
                                                         .Where(ra => ra.RoleId == 2 && ra.Status == true)
                                                         .ToList();
                return(View(customerList));
            }

            return(RedirectToAction("Index", "Login"));
        }
Ejemplo n.º 3
0
        public IActionResult Index()
        {
            if (HttpContext.Session.GetString("AdminId") != null)
            {
                ViewBag.NewOrder = _iInvoiceManager.GetAll()
                                   .Where(i => i.Status == false).ToList();
                ViewBag.TotalProducts = _iProductManager.GetAll();
                ViewBag.TotalCustomer = _iRoleAccountManager.GetAll().
                                        Where(ra => ra.RoleId == 2).ToList();
                ViewBag.TotalCategory = _iCategoryManager.GetAll()
                                        .Where(c => c.Categorye == null).ToList();
                return(View());
            }

            return(RedirectToAction("Index", "Login"));
        }