Beispiel #1
0
        public async Task <ActionResult> ResetPassword(int id)
        {
            BL.UserInfo empBL = new BL.UserInfo();
            if (empBL.GetItemByIdForDelete(id) != null)
            {
                return(Redirect(Url.Action("HttpError", "Error", new { area = "" })));
            }
            IPasswordPolicy Password        = new RandomPassword();
            string          orginalPassword = Password.GeneratePassword();

            orginalPassword = "******";
            string md5Password = HashEncrypt.MD5(orginalPassword);

            VM.UserInfoItem model = new VM.UserInfoItem();
            model = empBL.GetItemById(id);
            //IdentityModel user = await UserManager.FindByNameAsync(model.LogonName);
            //string password = UserManager.PasswordHasher.HashPassword(md5Password);
            //UserStore store = new UserStore(UserHelper.GetCurrentUser().LogonName);
            //var set = store.SetPasswordHashAsync(user, password);
            //var result = store.UpdateAsync(user);

            model.Password = md5Password;
            empBL.UpdatePasswordDb(model);
            if (model != null)
            {
                // empBL.SendEmail(model, orginalPassword, "User_ResetPassword");
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        //[AllowAnonymous]
        public async Task <ActionResult> UpdatePassword(VM.UserInfoUpdatePassword modelNew)
        {
            if (modelNew.UserId != Convert.ToInt32(UserHelper.GetCurrentUser().Id))
            {
                return(Redirect(Url.Action("Index", "NoPermissions", new { area = "" })));
            }
            BL.UserInfo     empBL = new BL.UserInfo();
            VM.UserInfoItem model = new VM.UserInfoItem();
            // model.UserId = CommonMethod.getIntValue(UserHelper.GetCurrentUser().Id);
            model = empBL.GetItemById(model.UserId);
            IdentityModel user = await UserManager.FindByNameAsync(model.LogonName);

            //modelNew.Password = HashEncrypt.MD5(modelNew.Password);
            var results = await UserManager.CheckPasswordAsync(user, modelNew.Password);

            if (results)
            {
                //modelNew.NewPassword = HashEncrypt.MD5(modelNew.NewPassword);
                string    password = UserManager.PasswordHasher.HashPassword(modelNew.NewPassword);
                UserStore store    = new UserStore(UserHelper.GetCurrentUser().LogonName);
                var       set      = store.SetPasswordHashAsync(user, password);
                var       result   = store.UpdateAsync(user);
                if (user != null)
                {
                    return(Content("Success"));
                }
            }
            else
            {
                return(Content("Error"));
            }
            return(Content("False"));
        }
Beispiel #3
0
        public ActionResult UserEdit()
        {
            ViewBag.ShowSubmit = true;
            BL.UserInfo empBL = new BL.UserInfo();
            int         id    = Convert.ToInt32(UserHelper.GetCurrentUser().Id);
            var         model = empBL.GetItemById(id);

            return(View(model));
        }
Beispiel #4
0
 public ActionResult GetUserSelectItem(MVC2015.Web.Model.SystemMaint.UserInfo.UserInfoSearch search, int currCompanyId, string currUserIds)
 {
     ViewBag.CurrCompanyId = currCompanyId;
     ViewBag.CurrUserIds   = currUserIds;
     BL.UserInfo userBL = new BL.UserInfo();
     MVC2015.Web.Model.SystemMaint.UserInfo.UserInfoModel userModel = new Model.SystemMaint.UserInfo.UserInfoModel();
     userModel.List   = userBL.GetAllUserItemForCompany(search);
     userModel.Search = search;
     return(PartialView("_UserSelectDialog", userModel));
 }
Beispiel #5
0
        //
        // GET: /SystemMaint/UserInfo/Details/5

        //
        // GET: /SystemMaint/UserInfo/Create
        public ActionResult Create()
        {
            ViewBag.ShowSubmit = true;
            VM.UserInfoItem model = new VM.UserInfoItem();
            model.StrStatus      = "1";
            model.RoleSelectList = GetRoleSelectList(model.RoleSelectList);
            //model.CompanySelectList = GetCompanySelectList(model.CompanySelectList);
            BL.UserInfo empBL = new BL.UserInfo();
            //  model.GasStationSelectList = empBL.GetAllGasStationSelectList();
            return(View(model));
        }
Beispiel #6
0
        public ActionResult GetDetail(int id)
        {
            BL.UserInfo empBL = new BL.UserInfo();
            if (empBL.GetItemByIdForDelete(id) != null)
            {
                return(Redirect(Url.Action("HttpError", "Error", new { area = "" })));
            }
            var model = empBL.GetItemById(id);

            return(PartialView("_Detail", model));
        }
Beispiel #7
0
        public ActionResult GetAllUserItem(UserInfoSearch search, int currRoleId, string currUserIds)
        {
            ViewBag.RoleId      = currRoleId;
            ViewBag.CurrUserIds = currUserIds;
            BL.UserInfo   userBL    = new BL.UserInfo();
            UserInfoModel usermodel = new Model.SystemMaint.UserInfo.UserInfoModel();

            usermodel.List   = userBL.GetAllItemById(search);
            usermodel.Search = search;
            return(PartialView("_UserSelectDialog", usermodel));
        }
Beispiel #8
0
        private List <MVC2015.Web.Model.SystemMaint.UserInfo.UserInfoItem> GetUserItems(int?companyId)
        {
            BL.UserInfo userBL = new BL.UserInfo();
            List <MVC2015.Web.Model.SystemMaint.UserInfo.UserInfoItem> userItems = new List <Model.SystemMaint.UserInfo.UserInfoItem>();

            if (companyId.HasValue)
            {
                userItems = userBL.GetItemByCompanyId(companyId.Value);
            }
            return(userItems);
        }
Beispiel #9
0
        public ActionResult UpdatePassword()
        {
            ViewBag.ShowSubmit = true;
            BL.UserInfo empBL = new BL.UserInfo();
            int         id    = Convert.ToInt32(UserHelper.GetCurrentUser().Id);
            var         model = empBL.GetItemById(id);

            VM.UserInfoUpdatePassword updtaePassword = new VM.UserInfoUpdatePassword();
            updtaePassword.UserId = model.UserId;
            return(View(updtaePassword));
        }
Beispiel #10
0
        private Model.SystemMaint.UserInfo.UserInfoModel GetUserItems(int?roleId)
        {
            BL.UserInfo   userBL    = new BL.UserInfo();
            UserInfoModel usermodel = new UserInfoModel();

            if (roleId.HasValue)
            {
                usermodel.List = userBL.GetItemByRoleId(roleId.Value);
            }

            return(usermodel);
        }
Beispiel #11
0
        //
        // GET: /SystemMaint/UserInfo/Edit/5
        public ActionResult Edit(int id)
        {
            ViewBag.ShowSubmit = true;
            BL.UserInfo empBL = new BL.UserInfo();
            if (empBL.GetItemByIdForDelete(id) != null)
            {
                return(Redirect(Url.Action("HttpError", "Error", new { area = "" })));
            }
            var model = empBL.GetItemById(id);

            model.RoleSelectList = GetRoleSelectList(model.RoleSelectList);
            //model.CompanySelectList = GetCompanySelectList(model.CompanySelectList);
            return(View(model));
        }
Beispiel #12
0
        private List <SelectListItem> GetRoleSelectList(List <SelectListItem> list)
        {
            BL.UserInfo           emp = new BL.UserInfo();
            List <SelectListItem> allRoleSelectList = emp.GetAllItems();

            //  var roleSelectList = (from a in allRoleSelectList select a.Text).Distinct().ToList();
            foreach (var item in allRoleSelectList)
            {
                list.Add(new SelectListItem {
                    Text = item.Text, Value = item.Value
                });
            }
            return(list);
        }
Beispiel #13
0
 public ActionResult GetGasStationMaps(int id, string value)
 {
     BL.UserInfo     empBL = new BL.UserInfo();
     VM.UserInfoItem model = new VM.UserInfoItem();
     if (id > 0)
     {
         model = empBL.GetItemById(id);
     }
     if (value != null)
     {
         //  model = empBL.GetItemByCompany(model, value);
     }
     model.UserCompanyValue = value;
     return(PartialView("_GasStationMap", model));
 }
Beispiel #14
0
 public ActionResult Edit(VM.UserInfoItem model)
 {
     BL.UserInfo empBL = new BL.UserInfo();
     if (empBL.ValidateName(model.UserId, model.LogonName))
     {
         return(Content(ResourceHelper.GetValue("SMM_UserInfo_SameLogonName")));
     }
     if (!new EmailExAttribute().IsValid(model.EmailAddress))
     {
         return(Content("False"));
     }
     model.UpdatedBy = "sysAdmin";// UserHelper.GetCurrentUser().LogonName;
     empBL.Update(model);
     return(Content("Success"));
 }
Beispiel #15
0
        public ActionResult UserEdit(VM.UserInfoItem model)
        {
            if (!new EmailExAttribute().IsValid(model.EmailAddress))
            {
                return(Content("False"));
            }
            BL.UserInfo empBL    = new BL.UserInfo();
            var         userEdit = empBL.GetItemById(model.UserId);

            userEdit.UserName     = model.UserName;
            userEdit.EmailAddress = model.EmailAddress;
            userEdit.UpdatedBy    = "sysAdmin";//UserHelper.GetCurrentUser().LogonName;
            empBL.UserUpdate(userEdit);

            return(Content("Success"));
        }
Beispiel #16
0
        //
        // GET: /SystemMaint/UserInfo/
        public ActionResult Index(VM.UserInfoSearch search)
        {
            SetViewBage();
            ViewBag.IsSortable = true;
            var model = new VM.UserInfoModel();

            ViewBag.DisplayDate = BasicParam.DatetimeFormat;
            BL.UserInfo empBL = new BL.UserInfo();
            model.List   = empBL.GetItems(search);
            model.Search = search;
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_List", model.List));
            }
            return(View(model));
        }
Beispiel #17
0
        public ActionResult Delete(int id)
        {
            BL.UserInfo empBL = new BL.UserInfo();
            if (empBL.GetItemByIdForDelete(id) != null)
            {
                return(Redirect(Url.Action("HttpError", "Error", new { area = "" })));
            }
            //if (id.ToString() == UserHelper.GetCurrentUser().Id)
            //{
            //    return Json("own", JsonRequestBehavior.AllowGet);
            //}
            //else
            //{
            bool result = empBL.Delete(id, "sysAdmin");    //UserHelper.GetCurrentUser().LogonName);

            return(Json(result, JsonRequestBehavior.AllowGet));
            //}
        }
Beispiel #18
0
        public ActionResult Edit(VM.RoleInfoItem model, List <ModulePermission> ModulePermissions, string allSelectList, int currRoleId, string deleteUserIds)
        {
            BL.RoleInfo empBL  = new BL.RoleInfo();
            BL.UserInfo userBL = new BL.UserInfo();
            if (empBL.ValidateName(model.RoleId, model.Name))
            {
                return(Content(ResourceHelper.GetValue("SMM_RoleInfo_NameExists")));
            }
            if (empBL.ValidateModulePermissions(ModulePermissions))
            {
                return(Content(ResourceHelper.GetValue("SMM_RoleInfo_AddPermissions")));
            }
            //empBL.e(model);
            model.UpdatedBy = UserHelper.GetCurrentUser().LogonName;
            empBL.Update(model, ModulePermissions);
            userBL.UpdateUserRole(allSelectList, currRoleId, deleteUserIds, model.UpdatedBy);

            //CacheDependencyHelper.Change(new string[] { BasicParam.RolePermissionCacheKey });

            return(Content("Success"));
        }
Beispiel #19
0
        public ActionResult GridView()
        {
            string json = Request.Params["searchModel"];

            VM.UserInfoSearch searchModel = new VM.UserInfoSearch();
            if (json != null)
            {
                try
                {
                    searchModel = JsonConvert.DeserializeObject(json, typeof(VM.UserInfoSearch)) as VM.UserInfoSearch;
                }
                catch
                {
                    return(Json("error", JsonRequestBehavior.AllowGet));
                }
            }
            BL.UserInfo empBL = new BL.UserInfo();
            var         model = empBL.GetItems(searchModel);

            ViewBag.DisplayDate = BasicParam.DatetimeFormat;
            return(PartialView("_List", model));
        }
Beispiel #20
0
        //[AllowAnonymous]
        public async Task <ActionResult> Create(VM.UserInfoItem model)
        {
            BL.UserInfo empBL = new BL.UserInfo();
            if (empBL.ValidateName(-1, model.LogonName))
            {
                return(Content(ResourceHelper.GetValue("SMM_UserInfo_SameLogonName")));
            }
            if (!new EmailExAttribute().IsValid(model.EmailAddress))
            {
                return(Content("False"));
            }
            var user = new IdentityModel();

            user.UserName            = model.LogonName;
            user.LogonName           = model.UserName;
            user.StrStatus           = model.StrStatus;
            user.RoleId              = model.RoleId;
            user.UserCompangValue    = model.UserCompanyValue;
            user.UserGasStationValue = model.UserGasStationValue;
            user.DomainAccount       = model.DomainAccount;
            user.EmailAddress        = model.EmailAddress;
            user.CreateBy            = "sysAdmin";//UserHelper.GetCurrentUser().LogonName;
            IPasswordPolicy Password        = new RandomPassword();
            string          orginalPassword = Password.GeneratePassword();
            string          md5Password     = HashEncrypt.MD5(orginalPassword);
            var             result          = await UserManager.CreateAsync(user, md5Password);

            if (result.Succeeded)
            {
                if (user.StrStatus == "1")
                {
                    //empBL.SendEmail(model, orginalPassword, "User_New");
                }
                return(Content("Success"));
            }

            return(Content("False"));
        }