public HttpResponseMessage LoginUser(UserModel model)
        {
            var sessionKey = GenerateSessionKey();

            var findEntity = this.userRepository.All().Where(x=> x.UserName == model.UserName && x.Password == model.Password).FirstOrDefault();

            if (findEntity == null)
            {
                var errorResponse = Request.CreateResponse(HttpStatusCode.BadRequest, "User does not exist.");

                return errorResponse;
            }

            findEntity.SessionKey = sessionKey;

            var createdModel = new UserModel()
            {
                UserId = findEntity.UserId,
                UserName = findEntity.UserName,
                FirstName = findEntity.FirstName,
                LastName = findEntity.LastName,
                Email = findEntity.Email,
                SessionKey = findEntity.SessionKey
            };

            this.userRepository.Update(findEntity.UserId, findEntity);

            var response = Request.CreateResponse<UserModel>(HttpStatusCode.OK, createdModel);
            var resourceLink = Url.Link("DefaultApi", new { UserId = createdModel.UserId });
            response.Headers.Location = new Uri(resourceLink);

            return response;
        }
        public HttpResponseMessage RegisterUser(UserModel model)
        {
            var sessionKey = GenerateSessionKey();

            var entityToAdd = new User()
            {
                FirstName = model.FirstName,
                LastName = model.LastName,
                UserName = model.UserName,
                Password = model.Password,
                Email = model.Email,
                SessionKey = sessionKey

            };

            var createEntity = this.userRepository.Add(entityToAdd);

            var createdModel = new UserModel()
            {
                UserId = createEntity.UserId,
                UserName = createEntity.UserName,
                FirstName = createEntity.FirstName,
                LastName = createEntity.LastName,
                Email = createEntity.Email,
                SessionKey = createEntity.SessionKey

            };

            var response = Request.CreateResponse<UserModel>(HttpStatusCode.Created, createdModel);
            var resourceLink = Url.Link("DefaultApi", new { UserId = createdModel.UserId });
            response.Headers.Location = new Uri(resourceLink);

            return response;
        }