示例#1
0
        public async Task<object> Register(string Username, string DisplayName, string Password, string Description)
        {
            UserProfile user = new UserProfile();
            //account.Userid = 0;
            user.Userid = Username;
            user.DisplayName = DisplayName;
            user.Password = Utils.MD5Encoding(Password);
            user.Description = Description;

            Task<UserProfile> createdUser = _accountManager.AddUser(user);
            UserProfile u = await createdUser;
            return u;            
        }
示例#2
0
        public async Task<Boolean> UpdateUser(UserProfile user)
        {
            UserProfile originUser = _accountCtx.Users.Find(user.Userid);
            if (originUser == null)
            {
                throw new UserNotFoundException(user.Userid);
            }

            originUser.DisplayName = user.DisplayName;
            originUser.PortraitUrl = user.PortraitUrl;
            originUser.Description = user.Description;
            await _accountCtx.SaveChangesAsync();
            return true;
        }
示例#3
0
 public async Task<UserProfile> AddUser(UserProfile user)
 {
     if (!Utils.IsValidID(user.Userid))
     {
         throw new InvalidIDException("User");
     }
     UserProfile temp = _accountCtx.Users.Find(user.Userid);
     if (temp != null)
     {
         throw new UserAlreadyExistException(user.Userid);
     }
     _accountCtx.Users.Add(user);
     await _accountCtx.SaveChangesAsync();
     return  _accountCtx.Users.Find(user.Userid);
 }