Ejemplo n.º 1
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"));
 }
Ejemplo n.º 2
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"));
        }