コード例 #1
0
        public ActionResult DeleteProcessByUser(string ID, ProcessByUser_Model objModel, int page = 1, int pageSize = 10)
        {
            ProcessByUserManager context = new ProcessByUserManager(new DataContext());

            if (!string.IsNullOrEmpty(ID))
            {
                int uId = Convert.ToInt32(ID);
                List <ProcessByUser> lst = context.GetAll(c => c.UserID == uId).ToList();
                context.DeleteProcessByUser(lst);

                VW_ProcessByUserManager context2 = new VW_ProcessByUserManager(new DataContext());
                int UserID = Convert.ToInt32(Session["UserID"]);
                VW_ProcessByUser objVW_ProcessByUser = context2.GetProcessByUserById(UserID);
                if (objVW_ProcessByUser != null)
                {
                    Session["UserProcess"] = objVW_ProcessByUser.ProcessName != null ? objVW_ProcessByUser.ProcessName : "";
                }
            }

            if (objModel.StaticPageSize != 0)
            {
                pageSize = objModel.StaticPageSize;
            }
            objModel.StaticPageSize = pageSize;

            BindProcessByUserGrid(objModel, page, pageSize);
            return(PartialView("ProcessByUserList", objModel));
        }
コード例 #2
0
        public ActionResult SaveProcessByUser(ProcessByUser_Model objModel, int page = 1, int pageSize = 10)
        {
            if (!ModelState.IsValid)
            {
                var message = string.Join("|", ModelState.Values.SelectMany(e => e.Errors).Select(em => em.ErrorMessage));
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, message));
            }

            //Save
            ProcessByUserManager    context  = new ProcessByUserManager(new DataContext());
            VW_ProcessByUserManager context2 = new VW_ProcessByUserManager(new DataContext());
            List <ProcessByUser>    lst      = context.GetAll(c => c.UserID == objModel.UserId).ToList();

            context.DeleteProcessByUser(lst);
            foreach (string pId in objModel.ProcessId)
            {
                ProcessByUserManager context1 = new ProcessByUserManager(new DataContext());
                ProcessByUser        obj      = new ProcessByUser();
                obj.ProcessID = Convert.ToInt32(pId);
                obj.UserID    = objModel.UserId;
                var msg = context1.SaveProcessByUser(obj);
            }
            int UserID = Convert.ToInt32(Session["UserID"]);
            VW_ProcessByUser objVW_ProcessByUser = context2.GetProcessByUserById(UserID);

            if (objVW_ProcessByUser != null)
            {
                Session["UserProcess"] = objVW_ProcessByUser.ProcessName != null ? objVW_ProcessByUser.ProcessName : "";
            }
            if (objModel.StaticPageSize != 0)
            {
                pageSize = objModel.StaticPageSize;
            }
            objModel.StaticPageSize = pageSize;

            BindProcessByUserGrid(objModel, page, pageSize);
            return(PartialView("ProcessByUserList", objModel));
        }
コード例 #3
0
        public ActionResult AddEditProcessByUser(int ID = 0)
        {
            ProcessListManager    objProcessListManager    = new ProcessListManager(new DataContext());
            UserMasterListManager objUserMasterListManager = new UserMasterListManager(new DataContext());
            //ProcessByUserManager context = new ProcessByUserManager(new DataContext());
            VW_ProcessByUserManager context  = new VW_ProcessByUserManager(new DataContext());
            ProcessByUser_Model     objModel = new ProcessByUser_Model();

            if (ID != 0)
            {
                objModel.Table     = context.GetProcessByUserById(ID);
                objModel.UserId    = objModel.Table.UserID;
                objModel.ProcessId = !string.IsNullOrEmpty(objModel.Table.ProcessID)? objModel.Table.ProcessID.Split(',') : null;
                objModel.UserList  = Extens.ToSelectList(objUserMasterListManager.GetDtUserListForProcess(objModel.Table.UserID), "UserID", "UserName");
            }
            else
            {
                objModel.Table    = new VW_ProcessByUser();
                objModel.UserList = Extens.ToSelectList(objUserMasterListManager.GetDtUserListForProcess(), "UserID", "UserName");
            }
            objModel.ProcessList = Extens.ToSelectList(objProcessListManager.GetDtProcess(), "ProcID", "Processname");

            return(PartialView("ProcessByUserCRUD", objModel));
        }
コード例 #4
0
        public ActionResult Login(LoginViewModel loginViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!this.IsCaptchaValid("Captcha is not valid"))
                    {
                        ModelState.AddModelError("", "Error: captcha is not valid.");
                        return(View(new LoginViewModel()));
                    }

                    if (!_iUserMaster.CheckUsernameExists(loginViewModel.Username))
                    {
                        ModelState.AddModelError("", "Invalid Credentails");
                        return(View(loginViewModel));
                    }

                    AesAlgorithm aesAlgorithm    = new AesAlgorithm();
                    var          usermasterModel = _iUserMaster.GetUserByUsername(loginViewModel.Username);
                    var          storedpassword  = aesAlgorithm.DecryptString(_password.GetPasswordbyUserId(usermasterModel.UserId));

                    if (storedpassword == loginViewModel.Password)
                    {
                        Session["UserID"]   = usermasterModel.UserId;
                        Session["Username"] = usermasterModel.UserName;
                        int UserID = Convert.ToInt32(usermasterModel.UserId);
                        VW_ProcessByUserManager context             = new VW_ProcessByUserManager(new DataContext());
                        VW_ProcessByUser        objVW_ProcessByUser = context.GetProcessByUserById(UserID);
                        if (objVW_ProcessByUser != null)
                        {
                            Session["UserProcess"] = objVW_ProcessByUser.ProcessName != null ? objVW_ProcessByUser.ProcessName : "";
                        }
                        var user = _iUserMaster.GetUserById(UserID);
                        SetOnlineUser(UserID.ToString());
                        Session["UserPhoto"] = user.ImageName;
                        if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId) != null)
                        {
                            // 1 is SuperAdmin
                            if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId == Convert.ToInt32(ConfigurationManager.AppSettings["SuperAdminRolekey"]))
                            {
                                Session["Role"]     = _savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId;
                                Session["RoleName"] = "SuperAdmin";
                                return(RedirectToAction("Dashboard", "SuperDashboard"));
                            }

                            // 2 is User
                            if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId == Convert.ToInt32(ConfigurationManager.AppSettings["UserRolekey"]))
                            {
                                Session["Role"]     = _savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId;
                                Session["RoleName"] = "User";
                                return(RedirectToAction("Dashboard", "UserDashboard"));
                            }

                            // 3 is Admin
                            if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId == Convert.ToInt32(ConfigurationManager.AppSettings["AdminRolekey"]))
                            {
                                Session["Role"]     = _savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId;
                                Session["RoleName"] = "Admin";
                                return(RedirectToAction("Dashboard", "AdminDashboard"));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Access Not Assigned");
                            return(View(loginViewModel));
                        }

                        return(RedirectToAction("Dashboard", "Dashboard"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid Credentails");
                        return(View(loginViewModel));
                    }
                }
                else
                {
                    return(View(loginViewModel));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }