public DatabaseResponse Post(UserRequest request, string username)
        {
            var user = this.GetLMConnectUser();
            var database = request.GetDatabase(user);

            if (user == null)
            {
                var owner = NotRegisteredUser.FromRequest(this.Request.Content.Headers);

                if (owner != null)
                {
                    // user to be registered
                    user = new LMConnect.Key.User
                    {
                        Username = owner.Username,
                        Password = owner.Password
                    };

                    this.Repository.Add(user);
                }
                else
                {
                    return ThrowHttpReponseException<DatabaseResponse>(
                        "No user for database.",
                        HttpStatusCode.BadRequest);
                }
            }

            if (database != null)
            {
                user.Databases.Add(database);

                this.Repository.Save(database);

                return new DatabaseResponse(database);
            }

            return ThrowHttpReponseException<DatabaseResponse>(
                "No database to register",
                HttpStatusCode.BadRequest);
        }
        public UserResponse Post(UserRequest request)
        {
            var user = this.Repository.Query<LMConnect.Key.User>()
                .FirstOrDefault(u => u.Username == request.name && u.Password == request.Password);

            if (user == null)
            {
                user = request.GetUser();

                this.Repository.Add(user);
            }

            var database = request.GetDatabase(user);

            if (database != null)
            {
                user.Databases.Add(database);
            }

            this.Repository.Save(user);

            return new UserResponse(user);
        }