Beispiel #1
0
        public ActionResult AddEditUser(UserListViewModel model)
        {
            FillAllDropdowns();

            string strSuccessMsg = string.Empty;
            string strErrorMsg = string.Empty;

            if (model != null && model.User != null)
            {
                if (string.IsNullOrEmpty(model.User.UserID))
                {
                    strSuccessMsg = UserRes.MsgAddSuccess;
                    strErrorMsg = UserRes.MsgAddError;
                }
                else
                {
                    strSuccessMsg = UserRes.MsgEditSuccess;
                    strErrorMsg = UserRes.MsgEditError;
                }

                int i = _ObjService.AddEdit(model.User);

                if (i <= 0)
                {
                    TempData["err"] = strErrorMsg;
                }
                else
                {
                    TempData["msg"] = strSuccessMsg;
                }
            }

            return RedirectToAction("ManageUser", "User");
        }
Beispiel #2
0
        public ActionResult AddEditUser(string pUserID)
        {
            FillAllDropdowns();

            User objUser = null;
            if (eSchoolSession.IsInSession(SessionKeys.CurrentUser))
                objUser = (User)eSchoolSession.GetDirectValue(SessionKeys.CurrentUser);

            UserListViewModel model = new UserListViewModel();
            model.User = new User();

            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(pUserID))
                {
                    model.User.UserID = pUserID;
                    model.User = _ObjService.GetUser(model.User);
                }

                if(string.IsNullOrEmpty(pUserID))
                {
                    model.User.IsActive = true;
                    model.User.IsLocked = false;
                }
                if (model.User.UserRoleRights != null)
                    model.UserRoleSelectList = model.User.UserRoleRights;
                else
                {
                    model.User.UserRoleRights = _userRoleRightsServices.GetAllRoles().ToList();
                    model.UserRoleSelectList = model.User.UserRoleRights;
                }

            }

            return View(model);
        }
Beispiel #3
0
        public ActionResult ManageUser(UserListViewModel model)
        {
            User objUser = null;
            if (eSchoolSession.IsInSession(SessionKeys.CurrentUser))
                objUser = (User)eSchoolSession.GetDirectValue(SessionKeys.CurrentUser);

            if (model.User == null)
            {
                model.User = new User();
            }

            if (!string.IsNullOrEmpty(model.User.sort))
            {
                model.User.SortExp = model.User.sort + " " + model.User.sortdir;
            }

            if (model.User.PageSize == 0)
            {
                int PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);
                model.User.PageSize = PageSize;
            }

            if (model.User.PageIndex == 0)
            {
                model.User.PageIndex = 1;
            }
            model.UserList = new List<User>();
            model.User.TotalCount = 0;

            //Searh Criteria
            if (model != null && model.User != null)
            {
                if (!string.IsNullOrEmpty(model.User.SearchUserName))
                    model.User.UserName = model.User.SearchUserName;

                if (!string.IsNullOrEmpty(model.User.SearchEmailAddress))
                    model.User.EmailAddress = model.User.SearchEmailAddress;
            }

            model.UserList = _ObjService.GetAllUser(model.User).ToList();
            Lookup entity = new Lookup();

            if (model.UserList != null && model.UserList.Count > 0)
            {
                int TotalCount = model.UserList[0].TotalCount;
                model.User.TotalCount = TotalCount;
            }

            return View(model);
        }
Beispiel #4
0
        public ActionResult DeleteUser(string pUserID)
        {
            if (!string.IsNullOrEmpty(pUserID))
            {
                UserListViewModel model = new UserListViewModel();
                model.User = new User();
                model.User.UserID = pUserID;
                int i = _ObjService.Delete(model.User);

                if (i <= 0)
                    TempData["err"] = UserRes.MsgDeleteError;
                else
                    TempData["msg"] = UserRes.MsgDeleteSuccess;
            }

            return RedirectToAction("ManageUser", "User");
        }