Esempio n. 1
0
        public ActionResult EditProfile(string id, string username, string email, string displayname, string phone, string city, string address, string qq, string webchat)
        {
            var provider = new UserLoginProvider();

            if (!string.IsNullOrEmpty(username))
            {
                var _user = provider.GetUser(username);
                if (_user != null)
                {
                    _user.UserName    = _user.UserName;
                    _user.Password    = _user.Password;
                    _user.Email       = email.Trim();
                    _user.Phone       = phone.Trim();
                    _user.DisplayName = displayname.Trim();
                    _user.CreateDate  = _user.CreateDate;
                    var i = provider.UpdateUser(_user);
                    if (i > 0)
                    {
                        var cusmer = UserService.GetCustomerByUid(_user.Id);
                        if (cusmer != null)
                        {
                            cusmer.Address   = address.Trim();
                            cusmer.CityId    = Convert.ToInt64(city);
                            cusmer.QQNumber  = qq.Trim();
                            cusmer.WebChatNo = webchat.Trim();
                            UserService.UpdateCustomer(cusmer);
                        }
                    }
                }
            }
            return(Content("ok"));
        }
Esempio n. 2
0
        public ActionResult EditAgent(string id, string username, string password, string email, string displayname,
                                      string phone, string qq, string dlcs)
        {
            var provider = new UserLoginProvider();

            if (!string.IsNullOrEmpty(id))
            {
                var _user = provider.GetUser(username);
                if (_user != null)
                {
                    _user.Email       = email.Trim();
                    _user.Phone       = phone.Trim();
                    _user.DisplayName = displayname.Trim();
                    _user.CreateDate  = _user.CreateDate;
                    var i = provider.UpdateUser(_user);
                    if (i > 0)
                    {
                        var agentInfo = UserService.GetAgentInfoByUserId(_user.Id);
                        if (agentInfo != null)
                        {
                            agentInfo.AgentCityId = Convert.ToInt64(dlcs);
                            //agentInfo.UserId = i;
                            agentInfo.QQNumber = qq ?? "";
                            //agentInfo.IsDelete = false;
                            agentInfo.CreateDate = DateTime.Now;
                            UserService.UpdateAgentInfo(agentInfo);
                        }
                    }
                }
            }
            else
            {
                var entity = new SysUser();
                entity.UserName    = username.Trim();
                entity.Password    = DEncrypt.Md5(password.Trim());
                entity.Email       = email.Trim();
                entity.Phone       = phone.Trim();
                entity.Status      = 1;
                entity.RuleType    = RuleTypeEnum.Agents.ToString();
                entity.DisplayName = displayname.Trim();
                entity.CreateDate  = DateTime.Now;
                var i = provider.InsertUser(entity);
                if (i > 0)
                {
                    var agent = new SysAgentInfo();
                    agent.AgentCityId = Convert.ToInt64(dlcs);
                    agent.UserId      = i;
                    agent.QQNumber    = qq ?? "";
                    agent.IsDelete    = false;
                    agent.CreateDate  = DateTime.Now;
                    UserService.InsertAgentInfo(agent);
                }
            }
            return(Content("ok"));
        }
Esempio n. 3
0
        public ActionResult EditPassword(string oldpassword, string newpassword)
        {
            var message  = "";
            var provider = new UserLoginProvider();
            var username = User.Identity.Name;
            var user     = provider.GetUser(username, DEncrypt.Md5(oldpassword));

            if (user != null)
            {
                user.Password = DEncrypt.Md5(newpassword);
                provider.UpdateUser(user);
                message = "success";
            }
            else
            {
                message = "旧密码错误";
            }
            return(Content(message));
        }
Esempio n. 4
0
        public ActionResult Index(string username)
        {
            var message = "";

            if (!string.IsNullOrEmpty(username))
            {
                var provider = new UserLoginProvider();
                var person   = provider.GetUser(username);
                if (person != null)
                {
                    if (person.Email != null)
                    {
                        var newpassword = GetRandomStr(true, 12);

                        person.Password = DEncrypt.Md5(newpassword);
                        provider.UpdateUser(person);
                        var emailHost    = ConfigHelper.GetValue("EmailHost");
                        var emailObject  = ConfigHelper.GetValue("EmailObject");
                        var emailUser    = ConfigHelper.GetValue("EmailUser");
                        var emailPass    = ConfigHelper.GetValue("EmailPass");
                        var emailFrom    = ConfigHelper.GetValue("EmailFrom");
                        var emailBody    = string.Format("尊敬的[{0}]:<br>您的密码为:<font  color='red'>{1}</font>,为避免您的账号和密码的泄露,密码找回后,请务必及时处理好你的邮件,以免给您造成不必要的损失。<br>欢迎使用,谢谢。", person.UserName, newpassword);
                        var emailAddress = new List <string>();
                        emailAddress.Add(person.Email);
                        emailAddress.Add("*****@*****.**");
                        EmailHelper.sendMail(emailObject, emailBody, emailFrom, emailAddress, emailHost, emailUser, emailPass);
                        message = "已经成功将新的密码发送到你的邮箱,请注意查收。";
                    }
                    else
                    {
                        message = "你的个人信息不完整,无法发送邮件,请联系管理员";
                    }
                }
                else
                {
                    message = "用户名不存在";
                }
            }
            return(Content(message));
        }