public async Task<IHttpActionResult> Register(RegisterModel userModel)
        {
            if (!ModelState.IsValid)
            {
                Log.Debug("Register failed with username: "******"User:  "******" already registered.");
                return BadRequest();
            }

            UserInfos info = new UserInfos();
            info.firstname = userModel.Firstname;
            info.lastname = userModel.Lastname;
            info.User_FK = result.Id;
            await db.SaveChangesAsync();
            db.UserInfos.Add(info);
            await db.SaveChangesAsync();

            Log.Debug("Register successful with username: " + userModel.email);

            return Ok();
        }
        public async Task<IdentityUser> registerUserWithUrlCode(UrlCodeModel code)
        {
            invitations invitation = (from model in db.invitations
                             where model.urlcode == code.urlcode
                             select model).First<invitations>();

            if (invitation == null)
                return null;

            RegisterModel user = new RegisterModel();

            user.Firstname = invitation.firstname;
            user.Lastname = invitation.lastname;
            user.Password = code.password;
            user.email = invitation.email;

            IdentityUser result = await _repo.RegisterUser(user);

            if (result == null)
                return null;

            UserInfos infos = new UserInfos();
            infos.firstname = invitation.firstname;
            infos.lastname = invitation.lastname;
            infos.User_FK = result.Id;

            User_Project_Rel rel = new User_Project_Rel();

            rel.type = invitation.type;
            rel.User_FK = result.Id;
            rel.Project_FK = invitation.Project_FK;

            db.User_Project_Rel.Add(rel);
            db.UserInfos.Add(infos);
            db.invitations.Remove(invitation);

            await db.SaveChangesAsync();

            return result;
        }