Ejemplo n.º 1
0
        /// <summary>
        /// 创建一个新用户,此用户待审核
        /// </summary>
        /// <param name="user"></param>
        /// <returns>是否成功创建</returns>
        public void NewUser(User user)
        {
            if (user == null)
            {
                throw new Exception("User对象不允许为空值");
            }
            if (String.IsNullOrEmpty(user.NickName) ||
                String.IsNullOrEmpty(user.RegisterName)||
                String.IsNullOrEmpty(user.RealName)||
                String.IsNullOrEmpty(user.Password))
            {
                throw new Exception(@"User对象中,NickName,RegisterName,RealName,
                 Password属性不允许为Null或者空字符串");
            }
            bool hasExistRegisterName = Register.HasExistRegisterName(user.RegisterName);
            bool hasExistNickName = Register.HasExistNickName(user.NickName);
            if (hasExistRegisterName)
            {
                throw new Exception("注册名已存在");
            }
            if (hasExistNickName)
            {
                throw new Exception("昵称已存在");
            }
            user.Id = DateTimeHelper.ConvertToIDString(DateTime.Now);
            user.Createtime = DateTime.Now;

            //此用户待审核,并未通过审核
            user.ApproveStatus = EnumUserApproveStatus.UnApproved;
            using (UserRepository userRepository = new UserRepository())
            {
                 userRepository.Add(user);
            }
        }
Ejemplo n.º 2
0
 public MemberViewModel(User user) {
     this.Id = user.Id;
     this.RegisterName = user.RegisterName;
     this.RealName = user.RealName;
     this.NickName = user.NickName;
     this.ContentGroupId = user.ContentGroupId;
     this.AuthorityCategory = user.AuthorityCategory;
     this.Gender = user.Gender;
     this.PersonalDescription = user.PersonalDescription;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 如果一个用户没有发表文章,则允许删除
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 bool IUserDeleteCheck.CanBeDeleted(User user)
 {
     bool userHasAriticles ;
     using(UserRepository repository = new UserRepository())
     {
         userHasAriticles = repository.IsUserHasAriticles(user.Id);
     }
     if(userHasAriticles)
         return false;
     else
         return true;
 }
Ejemplo n.º 4
0
        public static void TestAddUser()
        {
                var userRepository = new UserRepository();
                User user = new User();
                user.Id = "No.1";
                user.RealName = "mr111";
                user.AuthorityCategory = EnumUserCategory.Superman;
                user.RegisterName = "aswind";
                user.NickName = "被惊呆的小伙伴";
                user.Password = "******";
                user.Createtime = DateTime.Now;

                UserGroupRepository repository = new UserGroupRepository();
                UserGroup group=repository.FindByGroupTitle("R2Team");
               // UserGroup group1 = new UserGroup { Id = group.Id };
              //  userRepository.db.Entry(group1).State = EntityState.Unchanged;
               // user.ContentGroup = group1;
               // user.ContentGroup = new UserGroup();
                user.ContentGroupId = group.Id;
                userRepository.Add(user);
            }
Ejemplo n.º 5
0
 public string UserProfileMatchs(string userName, string passWord)
 {
     Login login = new Login();
     User user = login.UserProfileMatchs(userName,passWord);
     if (user != null)
     {
         User user2 = new User();
         user2.Id = user.Id;
         user2.RegisterName = user.RegisterName;
         user2.NickName = user.NickName;
         user2.Password = user.Password;
         user2.Createtime = user.Createtime;
         user2.AuthorityCategory = user.AuthorityCategory;
         user2.ContentGroupId = user.ContentGroupId;
         string result = JsonConvert.SerializeObject(user2);
         //string result = "success";
         return result;
     }
     else {
         return null;
     }
 }
Ejemplo n.º 6
0
 public string RegisterAction(string reginfo)
 {
     string regname = reginfo.Split('#')[0];
     string realnamer = reginfo.Split('#')[1];
     string nickname = reginfo.Split('#')[2];
     string password = reginfo.Split('#')[3];
     string explain = reginfo.Split('#')[4];
     string gender = reginfo.Split('#')[5];
     User user = new User();
     user.RegisterName = regname;
     user.RealName = realnamer;
     user.NickName = nickname;
     user.Password = password;
     user.PersonalDescription = explain;
     user.Createtime = System.DateTime.Now;
     EnumUserCategory userCat = EnumUserCategory.Visitor;
     user.AuthorityCategory = userCat;
     user.Gender = gender;
     Register reg = new BusinessModel.Register();
     reg.NewUser(user);
     return "success";
 }