Beispiel #1
0
        public List <UserModel> GetAll()
        {
            var allUsers = new List <UserModel>();

            foreach (var key in _keys)
            {
                Console.WriteLine("!!!!!!!!!!!!!!!");
                allUsers.Add(_convertModelsService.GetUserModel(JsonConvert.DeserializeObject <BackendUserModel>(_redisUsersDatabase.StringGet(key))));
            }

            return(allUsers);
        }
Beispiel #2
0
        public AuthenticationResult Register(string email, string password, string firstName, string lastName
                                             , CityModel city)
        {
            var existing = _users.Find(u => u.Email == email).FirstOrDefault();

            if (existing != null)
            {
                return(new AuthenticationResult
                {
                    Errors = new [] { "User with this username already exists" }
                });
            }

            var newUser = new BackendUserModel(null, email, password, firstName, lastName, city);

            _users.InsertOne(newUser);
            var user = _users.Find(u => u.Email == newUser.Email).FirstOrDefault();

            _redisUsersDatabase.StringSet(user.Id, JsonConvert.SerializeObject(user)
                                          , new TimeSpan(0, 1, 59, 59));

            return(GenerateAuthenticationResult(_convertModelsService.GetUserModel(newUser)));
        }