示例#1
0
        /// <summary>
        /// Login a User within system
        /// </summary>
        /// <returns></returns>
        public ActionResult UserLogin(string user = "", string pws = "", int SignOut = 0)
        {
            if (SignOut != 0)
            {
                Session["UserLogged"]   = null;
                Session["RoleLogged"]   = null;
                Session["UserIDLogged"] = null;

                return(View());
            }

            if (!string.IsNullOrWhiteSpace(user) && !string.IsNullOrWhiteSpace(pws))
            {
                MEmployees employee = new EmployeesController().Get().Where(u => u.Email == user && u.Password == pws).FirstOrDefault();

                if (employee == null)
                {
                    return(Json("Failed", JsonRequestBehavior.AllowGet));
                }

                if (employee.Active == false)
                {
                    return(Json("Inactive", JsonRequestBehavior.AllowGet));
                }

                string roleName = new RolesController().Get(int.Parse(employee.RoleID.ToString())).Name;
                string userName = string.Format("{0} {1}", employee.Name, employee.LastNames);

                Session["UserLogged"]   = userName;
                Session["RoleLogged"]   = roleName;
                Session["UserIDLogged"] = employee.EmployeeID;

                return(Json(Url.Content("~/Home/" + (roleName == "Admin" ? "DashboardAdmin" : "DashboardAdmin")), JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(View());
            }
        }
示例#2
0
        /// <summary>
        /// Admin Dashboard
        /// </summary>
        /// <returns></returns>
        public JsonResult Roles()
        {
            RolesController roles = new RolesController();

            return(Json(roles.Get(), JsonRequestBehavior.AllowGet));
        }