Ejemplo n.º 1
0
        public ActionResult Users()
        {
            int  action = 0;
            bool status = false;

            if (Session["Admin"] != null)
            {
                int      userId     = Convert.ToInt32(Session["Admin"]);
                string[] permission = CheckAdminPermissions.permission("Manage Users", userId);


                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }
            else if (Session["UserId"] != null)
            {
                int      userId     = Convert.ToInt32(Session["UserId"]);
                string[] permission = CheckPermissions.permission("Manage Users", userId);


                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }
            if (status == false)
            {
                string url = "~/Home/NoPermission";
                return(Redirect(url));
            }
            ViewBag.Action = action;
            ViewBag.Status = status;
            ManageUserModel  model    = new ManageUserModel();
            List <UserModel> UserList = new List <UserModel>();

            actionResult = adminAction.Users_LoadAll();
            if (actionResult.IsSuccess)
            {
                UserList = CommonMethods.ConvertTo <UserModel>(actionResult.dtResult);
            }
            model.UserList = UserList;
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Index(string type = "", string subtype = "", int subFeatureid = 0, int typeid = 0)
        {
            ViewBag.Type         = type;
            ViewBag.SubType      = subtype;
            ViewBag.SubFeatureid = subFeatureid;
            ViewBag.id           = typeid;
            int  action = 0;
            bool status = false;

            if (Session["Admin"] != null)
            {
                int      userId     = Convert.ToInt32(Session["Admin"]);
                string[] permission = CheckAdminPermissions.permission((type == "Employee" ? "Employees" : type), userId);


                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }
            else if (Session["UserId"] != null)
            {
                int      userId     = Convert.ToInt32(Session["UserId"]);
                string[] permission = CheckPermissions.permission((type == "Employee" ? "Employees" : type), userId);


                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }

            if (status == false)
            {
                string url = "~/Home/NoPermission";
                return(Redirect(url));
            }
            ViewBag.Action = action;
            ViewBag.Status = status;
            return(View());
        }
Ejemplo n.º 3
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var  controller = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();
            int  action     = 0;
            bool status     = false;

            if (filterContext.HttpContext.Session["Admin"] != null)
            {
                int      userId     = Convert.ToInt32(filterContext.HttpContext.Session["Admin"]);
                string[] permission = CheckAdminPermissions.permission(controller, userId);

                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }

            else if (filterContext.HttpContext.Session["UserId"] != null)
            {
                int      userId     = Convert.ToInt32(filterContext.HttpContext.Session["UserId"]);
                string[] permission = CheckPermissions.permission(controller, userId);


                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }
            if (status == false)
            {
                string url = "~/Home/NoPermission";
                filterContext.Result = new RedirectResult(url);
            }
            filterContext.Controller.ViewBag.Action = action;
            filterContext.Controller.ViewBag.Status = status;
        }
Ejemplo n.º 4
0
        public ActionResult DeleteUser(int?Id = 0)
        {
            int  action = 0;
            bool status = false;

            if (Session["Admin"] != null)
            {
                int      userId     = Convert.ToInt32(Session["Admin"]);
                string[] permission = CheckAdminPermissions.permission("Manage Users", userId);

                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }
            else if (Session["UserId"] != null)
            {
                int      userId     = Convert.ToInt32(Session["UserId"]);
                string[] permission = CheckPermissions.permission("Manage Users", userId);
                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }
            if (status == false)
            {
                string url = "~/Home/NoPermission";
                return(Redirect(url));
            }
            ViewBag.Action = action;
            ViewBag.Status = status;

            string json = string.Empty;

            try
            {
                UserBase userBase = new UserBase();
                userBase.ID = Convert.ToInt32(Id);

                actionResult = adminAction.User_DeleteById(userBase);
                if (actionResult.IsSuccess)
                {
                    int result = Convert.ToInt32(actionResult.dtResult.Rows[0][0]);
                    if (result == -10)
                    {
                        json = "-10";
                    }
                    else
                    {
                        json = "success";
                    }
                }
                else
                {
                    json = "-1";
                }
            }
            catch (Exception ex)
            {
                json = "-1";
                ErrorReporting.WebApplicationError(ex);
            }
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public ActionResult ManageUsers(int?Id = 0)
        {
            int  action = 0;
            bool status = false;

            if (Session["Admin"] != null)
            {
                int      userId     = Convert.ToInt32(Session["Admin"]);
                string[] permission = CheckAdminPermissions.permission("Manage Users", userId);

                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }
            else if (Session["UserId"] != null)
            {
                int      userId     = Convert.ToInt32(Session["UserId"]);
                string[] permission = CheckPermissions.permission("Manage Users", userId);
                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }
            if (status == false)
            {
                string url = "~/Home/NoPermission";
                return(Redirect(url));
            }
            ViewBag.Action = action;
            ViewBag.Status = status;
            UserModel model = new UserModel();

            if (Id > 0)
            {
                UserBase userBase = new UserBase();
                userBase.ID  = Convert.ToInt32(Id);
                actionResult = adminAction.User_LoadById(userBase);
                if (actionResult.IsSuccess)
                {
                    DataRow dr = actionResult.dtResult.Rows[0];
                    model.ID        = dr["ID"] != DBNull.Value ? Convert.ToInt32(dr["ID"]) : 0;
                    model.FirstName = dr["FirstName"] != DBNull.Value ? dr["FirstName"].ToString() : "";
                    model.LastName  = dr["LastName"] != DBNull.Value ? dr["LastName"].ToString() : "";
                    model.Initials  = dr["Initials"] != DBNull.Value ? dr["Initials"].ToString() : "";
                    model.UserName  = dr["UserName"] != DBNull.Value ? dr["UserName"].ToString() : "";

                    model.RegNumber      = dr["RegNumber"] != DBNull.Value ? dr["RegNumber"].ToString() : "";
                    model.Skills         = dr["Skills"] != DBNull.Value ? dr["Skills"].ToString() : "";
                    model.EMail          = dr["EMail"] != DBNull.Value ? dr["EMail"].ToString() : "";
                    model.UserName       = dr["UserName"] != DBNull.Value ? dr["UserName"].ToString() : "";
                    model.Roles          = dr["Roles"] != DBNull.Value ? dr["Roles"].ToString() : "";
                    model.UnitID         = dr["UnitID"] != DBNull.Value ? Convert.ToInt32(dr["UnitID"]) : 0;
                    model.IsDispatchable = dr["IsDispatchable"] != DBNull.Value ? Convert.ToBoolean(dr["IsDispatchable"]) : false;
                }

                actionResult = adminAction.UserRoles_LoadAll();
                if (actionResult.IsSuccess)
                {
                    model.RolesList = CommonMethods.ConvertTo <Roles>(actionResult.dtResult);
                }
            }
            return(View(model));
        }
Ejemplo n.º 6
0
        public ActionResult RolePermissions(int?Id = 0)
        {
            int  action = 0;
            bool status = false;

            if (Session["Admin"] != null)
            {
                int      userId     = Convert.ToInt32(Session["Admin"]);
                string[] permission = CheckAdminPermissions.permission("Manage Roles", userId);


                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }

            else if (Session["UserId"] != null)
            {
                int      userId     = Convert.ToInt32(Session["UserId"]);
                string[] permission = CheckPermissions.permission("Manage Roles", userId);


                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }
            }
            if (status == false)
            {
                string url = "~/Home/NoPermission";
                return(Redirect(url));
            }
            ViewBag.Action = action;
            ViewBag.Status = status;
            Roles        model    = new Roles();
            List <Roles> roleList = new List <Roles>();

            model.RolesList = roleList;
            model.RoleId    = Convert.ToInt32(Id);

            actionResult = adminAction.UserRoles_LoadAll();
            if (actionResult.IsSuccess)
            {
                model.RolesList = CommonMethods.ConvertTo <Roles>(actionResult.dtResult);
            }

            if (model.RoleId > 0)
            {
                for (int i = 0; i < model.RolesList.Count; i++)
                {
                    if (model.RolesList[i].RoleId == model.RoleId)
                    {
                        ViewBag.RoleName = model.RolesList[i].RoleName;
                        ViewBag.RoleID   = model.RolesList[i].RoleId;
                    }
                }
            }
            if (ViewBag.RoleName == null)
            {
                ViewBag.RoleName = "";
            }

            if (model.RolesList.Count > 0 && Id == 0)
            {
                model.RoleId = model.RolesList[0].RoleId;
            }


            actionResult = adminAction.Menus_LoadForSiteAdministrator();
            if (actionResult.IsSuccess)
            {
                model.MenusList = CommonMethods.ConvertTo <Menus>(actionResult.dtResult);
            }
            //.OrderBy(m => m.ParentId).ToList()

            //actionResult = adminAction.SubMenu_LoadAll();
            //if (actionResult.IsSuccess)
            //    model.SubMenusList = CommonMethods.ConvertTo<SubMenus>(actionResult.dtResult);

            //roleBase.ID = Convert.ToInt32(Id);
            //SubMenus subMenusModel = new SubMenus();
            //actionResult = adminAction.SubMenuPermissions(roleBase);
            //if (actionResult.IsSuccess)
            //{
            //    DataRow dr = actionResult.dtResult.Rows[0];
            //    subMenusModel.ParentID = dr["ParentID"] != DBNull.Value ? Convert.ToInt32(dr["ParentID"]) : 0;
            //    subMenusModel.Roles = dr["SubMenus"] != DBNull.Value ? dr["SubMenus"].ToString() : "";
            //}
            //model.SubMenusModel = subMenusModel;
            // dhaval

            DataTable dt = new DataTable();

            dt = getbackground("");

            if (dt.Rows.Count > 0 && dt.Rows[0]["Corporate_logo"].ToString().Length > 0)
            {
                ViewBag.Corporate_logo = dt.Rows[0]["Corporate_logo"].ToString();
            }
            else
            {
                ViewBag.Corporate_logo = "admin-logo.png";
            }

            if (dt.Rows.Count > 0 && dt.Rows[0]["Customer_logo"].ToString().Length > 0)
            {
                ViewBag.Customer_logo = dt.Rows[0]["Customer_logo"].ToString();
            }
            else
            {
                ViewBag.Customer_logo = "";
            }

            if (dt.Rows.Count > 0 && dt.Rows[0]["Corporate_background"].ToString().Length > 0)
            {
                ViewBag.Corporate_background = dt.Rows[0]["Corporate_background"].ToString();
            }
            else
            {
                ViewBag.Corporate_background = "#f79646";
            }

            if (dt.Rows.Count > 0 && dt.Rows[0]["Corporate_back_type"].ToString().Length > 0)
            {
                ViewBag.Corporate_back_type = dt.Rows[0]["Corporate_back_type"].ToString();
            }
            else
            {
                ViewBag.Corporate_back_type = "palette";
            }

            return(View(model));
        }
Ejemplo n.º 7
0
        public ActionResult Index()
        {
            CIMS.ActionLayer.Employee.EmployeeAction employeeAction = new CIMS.ActionLayer.Employee.EmployeeAction();
            CIMS.BaseLayer.Employee.EmployeeBase     employeeBase   = new CIMS.BaseLayer.Employee.EmployeeBase();
            List <EmployeeModel> employeeList = new List <EmployeeModel>();
            EmployeeModel        model        = new EmployeeModel();

            employeeBase.UserID = Convert.ToInt32(Session["UserId"]);
            employeeBase.RoleID = Convert.ToInt32(Session["RoleId"]);
            actionResult        = employeeAction.Employees_dashboard(employeeBase);
            if (actionResult.IsSuccess && actionResult.dtResult.Rows.Count > 0)
            {
                employeeList = (from DataRow row in actionResult.dtResult.Rows
                                select new EmployeeModel
                {
                    EmployeeID = row["EmployeeID"] != DBNull.Value ? Convert.ToInt32(row["EmployeeID"]) : 0,
                    FirstName = row["FirstName"] != DBNull.Value ? row["FirstName"].ToString() : "",
                    MiddleName = row["MiddleName"] != DBNull.Value ? row["MiddleName"].ToString() : "",
                    LastName = row["LastName"] != DBNull.Value ? row["LastName"].ToString() : "",
                    CreatedByUser = row["CreatedByUser"] != DBNull.Value ? row["CreatedByUser"].ToString() : "",
                    CreatedDate = row["CreatedDate"] != DBNull.Value ? row["CreatedDate"].ToString() : "",
                    TotalEmployees = row["TotalEmployees"] != DBNull.Value ? row["TotalEmployees"].ToString() : "",
                    FilePath = row["FilePath"] != DBNull.Value ? Convert.ToString(row["FilePath"]) : null
                }).ToList();
            }
            CIMS.ActionLayer.VisitorAction visitorAction = new CIMS.ActionLayer.VisitorAction();
            List <VisitorModel>            visitorList   = new List <VisitorModel>();
            VisitorModel visitorModel = new VisitorModel();

            actionResult = visitorAction.Visitor_dashboard();
            if (actionResult.IsSuccess && actionResult.dtResult.Rows.Count > 0)
            {
                visitorList = (from DataRow row in actionResult.dtResult.Rows
                               select new VisitorModel
                {
                    VisitorID = row["VisitorID"] != DBNull.Value ? Convert.ToInt32(row["VisitorID"]) : 0,
                    VisitorName = row["VisitorName"] != DBNull.Value ? row["VisitorName"].ToString() : "",
                    CreatedByUser = row["CreatedByUser"] != DBNull.Value ? row["CreatedByUser"].ToString() : "",
                    CreatedDate = row["CreatedDate"] != DBNull.Value ? row["CreatedDate"].ToString() : "",
                    TotalVisit = row["TotalVisit"] != DBNull.Value ? row["TotalVisit"].ToString() : "",
                    ImagePath = row["ImagePath"] != DBNull.Value ? row["ImagePath"].ToString() : ""
                }).ToList();
            }
            CIMS.ActionLayer.Subject.SubjectAction subjectAction = new CIMS.ActionLayer.Subject.SubjectAction();
            CIMS.BaseLayer.Subject.SubjectBase     subjectBase   = new CIMS.BaseLayer.Subject.SubjectBase();
            List <SubjectModel> subjectList  = new List <SubjectModel>();
            SubjectModel        subjectModel = new SubjectModel();

            subjectBase.CreatedBy = Convert.ToInt32(Session["UserId"]);
            subjectBase.RoleID    = Convert.ToInt32(Session["RoleId"]);
            actionResult          = subjectAction.Subject_dashboard(subjectBase);
            if (actionResult.IsSuccess && actionResult.dtResult.Rows.Count > 0)
            {
                subjectList = (from DataRow row in actionResult.dtResult.Rows
                               select new SubjectModel
                {
                    SubjectID = row["SubjectID"] != DBNull.Value ? Convert.ToInt32(row["SubjectID"]) : 0,
                    FirstName = row["FirstName"] != DBNull.Value ? row["FirstName"].ToString() : "",
                    MiddleName = row["MiddleName"] != DBNull.Value ? row["MiddleName"].ToString() : "",
                    LastName = row["LastName"] != DBNull.Value ? row["LastName"].ToString() : "",
                    CreatedByUser = row["CreatedByUser"] != DBNull.Value ? row["CreatedByUser"].ToString() : "",
                    ModifiedDate = row["ModifiedDate"] != DBNull.Value ? row["ModifiedDate"].ToString() : "",
                    TotalSubjects = row["TotalSubjects"] != DBNull.Value ? row["TotalSubjects"].ToString() : "",
                    FilePath = row["FilePath"] != DBNull.Value ? Convert.ToString(row["FilePath"]) : null
                }).ToList();
            }
            model.EmployeeList = employeeList;

            visitorModel.VisitorList = visitorList;
            model.visitorNewModel    = visitorModel;

            subjectModel.SubjectList = subjectList;
            model.subjectNewModel    = subjectModel;


            // dhaval

            DataTable dt = new DataTable();

            dt = getbackground("");

            if (dt.Rows.Count > 0 && dt.Rows[0]["Corporate_logo"].ToString().Length > 0)
            {
                ViewBag.Corporate_logo = dt.Rows[0]["Corporate_logo"].ToString();
            }
            else
            {
                ViewBag.Corporate_logo = "admin-logo.png";
            }

            if (dt.Rows.Count > 0 && dt.Rows[0]["Customer_logo"].ToString().Length > 0)
            {
                ViewBag.Customer_logo = dt.Rows[0]["Customer_logo"].ToString();
            }
            else
            {
                ViewBag.Customer_logo = "admin-logo.png";
            }

            if (dt.Rows.Count > 0 && dt.Rows[0]["Corporate_background"].ToString().Length > 0)
            {
                ViewBag.Corporate_background = dt.Rows[0]["Corporate_background"].ToString();
            }
            else
            {
                ViewBag.Corporate_background = "#f79646";
            }

            if (dt.Rows.Count > 0 && dt.Rows[0]["Corporate_back_type"].ToString().Length > 0)
            {
                ViewBag.Corporate_back_type = dt.Rows[0]["Corporate_back_type"].ToString();
            }
            else
            {
                ViewBag.Corporate_back_type = "palette";
            }


            // Employee

            var controller  = "Employees";
            var controller1 = "Subject";

            int  action = 0;
            bool status = false;

            int  action1 = 0;
            bool status1 = false;

            if (Session["Admin"] != null)
            {
                int      userId     = Convert.ToInt32(Session["Admin"].ToString());
                string[] permission = CheckAdminPermissions.permission(controller, userId);


                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }

                permission = CheckAdminPermissions.permission(controller1, userId);


                if (permission != null)
                {
                    action1 = Convert.ToInt32(permission[1]);
                    status1 = Convert.ToBoolean(permission[0]);
                }
            }

            else if (Session["UserId"] != null)
            {
                int      userId     = Convert.ToInt32(Session["UserId"].ToString());
                string[] permission = CheckPermissions.permission(controller, userId);


                if (permission != null)
                {
                    action = Convert.ToInt32(permission[1]);
                    status = Convert.ToBoolean(permission[0]);
                }

                permission = CheckPermissions.permission(controller1, userId);


                if (permission != null)
                {
                    action1 = Convert.ToInt32(permission[1]);
                    status1 = Convert.ToBoolean(permission[0]);
                }
            }

            ViewBag.Action = action;
            ViewBag.Status = status;

            ViewBag.Action1 = action1;
            ViewBag.Status1 = status1;

            // Subject


            return(View(model));
        }