public HttpResponseMessage Login(LoginRequest model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var    webClient         = new WebClient();
                    string verification      = webClient.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", _configService.ConvertConfigValue_String("Google_Recaptcha"), model.recaptchaResponse));
                    var    recaptchaResponse = (JObject.Parse(verification)["success"].Value <bool>());

                    // checking for third party login
                    ThirdPartyUserLogin check = _thirdPartyUserService.GetByEmail(model.Email);
                    if (check.ThirdPartyTypeId > 0)
                    {
                        ErrorResponse resp = new ErrorResponse("Uncessful Login Attempt, user is registered with third party service");
                        return(Request.CreateResponse(HttpStatusCode.OK, resp));
                    }
                    else
                    {
                        IUserAuthData success = _userService.LogIn(model.Email, model.Password);

                        if (success != null)
                        {
                            List <int> pID = _userService.GetPerson(success.Id);
                            LoginResponse <IUserAuthData> resp = new LoginResponse <IUserAuthData>();
                            resp.Item     = success;
                            resp.PersonID = pID;
                            return(Request.CreateResponse(HttpStatusCode.OK, resp));
                        }
                        else
                        {
                            ErrorResponse resp = new ErrorResponse("Uncessful Login Attempt");
                            return(Request.CreateResponse(HttpStatusCode.OK, resp));
                        }
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
        public HttpResponseMessage SignIn(ThirdPartyUserLogin model)
        {
            try
            {
                //check if user exists
                ThirdPartyUserLogin check = _thirdPartyService.GetByEmail(model.Email);

                if (check == null)
                {
                    //Register User
                    int result = _thirdPartyService.Create(model);

                    //If the registration does not work
                    if (result == null || result <= 0)
                    {
                        ErrorResponse resp = new ErrorResponse("Unsuccessful Registration Attempt");
                        return(Request.CreateResponse(HttpStatusCode.OK, resp));
                    }
                    //If succesfull, log the user in
                    else
                    {
                        IUserAuthData success = _userService.LogIn(model.Email, model.Password);

                        if (success != null)
                        {
                            List <int> pID = _userService.GetPerson(success.Id);
                            LoginResponse <IUserAuthData> resp = new LoginResponse <IUserAuthData>();
                            resp.Item     = success;
                            resp.PersonID = pID;
                            return(Request.CreateResponse(HttpStatusCode.OK, resp));
                        }
                        else
                        {
                            ErrorResponse resp = new ErrorResponse("Uncessful Login Attempt");
                            return(Request.CreateResponse(HttpStatusCode.OK, resp));
                        }
                    }
                }
                else //check for 3rd Party Type
                {
                    if (check.ThirdPartyTypeId > 0)
                    {
                        IUserAuthData success = _userService.LogIn(model.Email, model.Password);

                        if (success != null)
                        {
                            List <int> pID = _userService.GetPerson(success.Id);
                            LoginResponse <IUserAuthData> resp = new LoginResponse <IUserAuthData>();
                            resp.Item     = success;
                            resp.PersonID = pID;
                            return(Request.CreateResponse(HttpStatusCode.OK, resp));
                        }
                        else
                        {
                            ErrorResponse resp = new ErrorResponse("Uncessful Login Attempt");
                            return(Request.CreateResponse(HttpStatusCode.OK, resp));
                        }
                    }
                    else
                    {
                        ErrorResponse resp = new ErrorResponse("Uncessful Login Attempt. User is already registered.");
                        return(Request.CreateResponse(HttpStatusCode.OK, resp));
                    }
                }
            }//Mdoel State Valid
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
            }
        }