Пример #1
0
        public long AddUser(UserInfoModel user)
        {
            var role = _entity.blog_roles.FirstOrDefault(x => x.roleid == user.RoleId) ?? AddRole(user.RoleId);
            var dbuser = new blog_users
            {
                username = user.UserName,
                userpwd = user.UserPwd,
                usercreatedate = DateTime.Now,
                lastlogindate = DateTime.Now,
                lastactivitydate = DateTime.Now,
                blog_roles = role,
                userstate = 1
            };

            _entity.blog_users.AddObject(dbuser);
            _entity.SaveChanges();

            return dbuser.userid;
        }
Пример #2
0
        private void AddUserProfile(UserInfoModel user)
        {
            var dbuserProfile = new blog_userprofile
            {
                userid = user.UserId,
                gender = user.Gender,
                nickname = user.NickName,
                signature = user.Signature,
                intro = user.Intro,
                birth = user.Birth,
                location = user.Location,
                website = user.Website,
                qq = user.Qq,
                sina = user.Sina,
                facebook = user.Facebook,
                twitter = user.Twitter,
                medals = user.Medals,
                phone = user.Phone,
                email = user.Email,
                isSendEmail = user.IsSendEmail
            };

            _entity.blog_userprofile.AddObject(dbuserProfile);
            _entity.SaveChanges();
        }
Пример #3
0
 public ActionResult UserProfile(UserProfileModel model)
 {
     var userinfo = new UserInfoModel
         {
             UserName = UserInfo.username,
             NickName = model.NickName,
             Signature = model.Signature,
             Intro = model.Intro,
             Gender = model.Gender,
             Birth = model.Birth,
             Location = model.Location,
             Website = model.Website,
             Qq = model.Qq,
             Sina = model.Sina,
             Facebook = model.Facebook,
             Twitter = model.Twitter,
             Medals = model.Medals,
             Phone = model.Phone,
             Email = model.Email,
             IsSendEmail = model.IsSendEmail
         };
     MyService.UpdateUserProfile(userinfo);
     return Content("", "text/html;charset=UTF-8");
 }
Пример #4
0
        public void UpdateUserProfile(UserInfoModel user)
        {
            var dbuser = _entity.blog_users.FirstOrDefault(m => m.username == user.UserName);
            if(dbuser==null)
            {  return;}
            var query = _entity.blog_userprofile.FirstOrDefault(m => m.userid == dbuser.userid);
            if (query == null)
            {
                user.UserId = dbuser.userid;
                AddUserProfile(user);
                return;
            }
            query.gender = user.Gender;
            query.nickname = user.NickName;
            query.signature = user.Signature;
            query.intro = user.Intro;
            query.birth = user.Birth;
            query.location = user.Location;
            query.website = user.Website;
            query.qq = user.Qq;
            query.sina = user.Sina;
            query.facebook = user.Facebook;
            query.twitter = user.Twitter;
            query.medals = user.Medals;
            query.phone = user.Phone;
            query.email = user.Email;
            query.isSendEmail = user.IsSendEmail;

            _entity.SaveChanges();
        }
Пример #5
0
 public ActionResult Register(RegisterModel model)
 {
     var re = string.Empty;
     if (ModelState.IsValid)
     {
         if (!MyService.UserExist(model.UserName.Trim()))
         {
             var user = new UserInfoModel
             {
                 UserName = model.UserName.Trim(),
                 UserPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password, "md5"),
                 RoleId = GetRoleId(model.UserName)
             };
             MyService.AddUser(user);
             Session.Add("user", MyService.UserExist(user.UserName, user.UserPwd));
         }
         else
         {
             re = res.Register_UsernameExists;
         }
     }
     else
     {
         re = res.SysError;
     }
     return Content(re, "text/html;charset=UTF-8");
 }