Beispiel #1
0
 //判断注册
 public bool Register(Userinfo user)
 {
     if (LoginIdExists(user.UserId))
     {
         return(false);
     }
     else
     {
         AddUser(user);
         return(true);
     }
 }
 //用Id查询
 public string GetById(int countid)
 {
     string jsonstr = "";
     try
     {
         Model.hp_count model = entity.hp_count.First(o => o.id == countid);
         Userinfo userinfo = new Userinfo(model);
         jsonstr = ReturnJson.toJson("100", "成功", userinfo);
     }
     catch (Exception e)
     {
         jsonstr = ReturnJson.toJson("101", "失败", -1);
     }
     return jsonstr;
 }
Beispiel #3
0
        public bool Login(string UserId, string loginPwd, out Userinfo validUser)
        {
            UserSerice us   = new UserSerice();
            Userinfo   user = us.GetUserById(UserId);

            if (user == null)
            {
                //用户名不存在
                validUser = null;
                return(false);
            }
            if (user.Pwd == loginPwd)
            {
                validUser = user;
                return(true);
            }
            else
            {
                //密码错误
                validUser = null;
                return(false);
            }
        }
 //修改数据
 public string Edit(Userinfo minfo)
 {
     string jsonstr = "";
     try
     {
         Model.hp_userinfo model = entity.hp_userinfo.First(o => o.countid == minfo.countid);
         if (minfo.icon != null && minfo.icon != "")
             model.icon = minfo.icon;
         if (minfo.nickname != null && minfo.nickname != "")
             model.nickname = minfo.nickname;
         if (minfo.sex != StringHelper.NONEVALUE)
              model.sex = minfo.sex;
         if (minfo.industry != null && minfo.industry != "")
             model.industry = minfo.industry;
         if (minfo.job != null && minfo.job != "")
             model.job = minfo.job;
         if (minfo.school != null && minfo.school != "")
             model.school = minfo.school;
         if (minfo.borndate != null && minfo.borndate != "")
             model.borndate = Convert.ToDateTime(minfo.borndate);
         if (minfo.starid != StringHelper.NONEVALUE)
             model.starid = minfo.starid;
         if (minfo.btypeid != StringHelper.NONEVALUE)
             model.btypeid = minfo.btypeid;
         if (minfo.persign != null && minfo.persign != "")
             model.persign = minfo.persign;
         entity.SaveChanges();
         jsonstr = ReturnJson.toJson("100", "成功", -1);
         return jsonstr;
     }
     catch (Exception e)
     {
         jsonstr = ReturnJson.toJson("101", "失败", -1);
         return jsonstr;
     }
 }
 //修改头像路径
 private Userinfo ChangeIcon(Userinfo userinfo)
 {
     string Path = userinfo.icon;
     userinfo.icon = StringHelper.IMGURL + Path;
     return userinfo;
 }
Beispiel #6
0
 //注册
 public void AddUser(Userinfo user)
 {
     us.Add_Users(user);
 }