Beispiel #1
0
        public Boolean TrySignUp(String nickname, String password)
        {
            IDataBaseAccessService client = SDbService.Get();

            if (client.FindUserByNickname(nickname) != null)
            {
                return(false);
            }
            Guid   userId = Guid.NewGuid();
            String salt   = CSaltGenerator.Instance.GetNewSalt();
            CUser  user   = new CUser
            {
                Nickname         = nickname,
                UserId           = userId,
                RegistrationDate = DateTime.UtcNow,
                Authentication   = new CAuthentication()
                {
                    UserId       = userId,
                    Salt         = salt,
                    PasswordHash = ComputePasswordHash(password, salt)
                }
            };

            return(client.AddUser(user));
        }
Beispiel #2
0
        public GamePage(CGameStartModel model)
        {
            InitializeComponent();
            IDataBaseAccessService client = SDbService.Get();

            switch (model.MySideColor)
            {
            case EPieceColor.White:
                WhitePlayerBadge.Content = new PlayerBadgeControl(
                    CAuthenticationStaff.Instance.User.Nickname,
                    client.GetWinRate(CAuthenticationStaff.Instance.User.UserId));
                BlackPlayerBadge.Content = new PlayerBadgeControl(
                    client.FindUserById(model.OpponentId).Nickname,
                    client.GetWinRate(model.OpponentId));
                break;

            case EPieceColor.Black:
                WhitePlayerBadge.Content = new PlayerBadgeControl(
                    client.FindUserById(model.OpponentId).Nickname,
                    client.GetWinRate(model.OpponentId));
                BlackPlayerBadge.Content = new PlayerBadgeControl(
                    CAuthenticationStaff.Instance.User.Nickname,
                    client.GetWinRate(CAuthenticationStaff.Instance.User.UserId));
                break;

            default:
                throw new InvalidEnumArgumentException("Unknown or undefined player side color");
            }
            DataContext = new CGamePageViewModel(model.GameId, model.MySideColor);
        }
Beispiel #3
0
        public CUser TryLogIn(String nickname, String password)
        {
            IDataBaseAccessService client = SDbService.Get();
            CUser user = client.FindRegisteredUser(nickname);

            if (user == null)
            {
                return(null);
            }
            if (_onlineUsers.Contains(user.UserId))
            {
                return(null);
            }
            if (!ComputePasswordHash(password, user.Authentication.Salt).SequenceEqual(user.Authentication.PasswordHash))
            {
                return(null);
            }
            _onlineUsers.Add(user.UserId);
            user.Authentication = null;
            return(user);
        }
 public SerieRepository(IDataBaseAccessService dataBaseAccessService) : base(dataBaseAccessService)
 {
 }
Beispiel #5
0
 public Repository(IDataBaseAccessService dataBaseAccessService)
 {
     this.dataBaseAccessService = dataBaseAccessService;
 }
 public LocalDataBaseRepository(IDataBaseAccessService dataBaseAccessService)
 {
     this.dataBaseAccessService = dataBaseAccessService;
     liteCollection             = GetCollection();
 }
Beispiel #7
0
 public GenericRepository(IDataBaseAccessService dataBaseAccessService) : base(dataBaseAccessService.GetDataBasePath())
 {
     CreateTable <T>();
 }
        public Repository(IDataBaseAccessService dataBaseAccessService) : base(dataBaseAccessService.GetDataBasePath())
        {
            this.dataBaseAccessService = dataBaseAccessService;

            CreateTable <T>();
        }