public HttpResponseMessage Post([FromBody] CheckProfileRequest request)
        {
            HttpResponseMessage response;

            try
            {
                var technologiesResponse = TechnologiesController.CreateTechnologiesResponse();

                CheckProfileResponse checkProfileResponse = new CheckProfileResponse()
                {
                    Cities                = technologiesResponse.Cities,
                    AudienceOrgTypes      = technologiesResponse.AudienceOrgTypes,
                    AudienceTypes         = technologiesResponse.AudienceTypes,
                    SecondaryTechnologies = technologiesResponse.SecondaryTechnologies,
                };

                using (DbModel.TechReadyDbContext ctx = new DbModel.TechReadyDbContext())
                {
                    var appUser = (from c in ctx.AppUsers
                                   where
                                   c.AuthProviderName == request.AuthProvider &&
                                   c.AuthProviderUserId == request.AuthProviderUserId
                                   select c).FirstOrDefault();

                    if (appUser != null)
                    {
                        checkProfileResponse.City = new City()
                        {
                            CityName = appUser.CityName,
                        };
                        if (appUser.City.Location != null)
                        {
                            checkProfileResponse.City.Location = new GeoCodeItem()
                            {
                                Latitude  = appUser.City.Location.Latitude,
                                Longitude = appUser.City.Location.Longitude
                            };
                        }

                        if (appUser.Location != null)
                        {
                            checkProfileResponse.Location = new GeoCodeItem()
                            {
                                Latitude  = appUser.Location.Latitude,
                                Longitude = appUser.Location.Longitude
                            };
                        }

                        checkProfileResponse.Town = appUser.Town;

                        checkProfileResponse.AuthProvider       = request.AuthProvider;
                        checkProfileResponse.AuthProviderUserId = request.AuthProviderUserId;
                        checkProfileResponse.Email                   = appUser.Email;
                        checkProfileResponse.FullName                = appUser.FullName;
                        checkProfileResponse.IsRegistered            = true;
                        checkProfileResponse.UserId                  = appUser.AppUserID.ToString();
                        checkProfileResponse.DeviceId                = appUser.DeviceId;
                        checkProfileResponse.SelectedAudienceOrgType = new AudienceOrg()
                        {
                            AudienceTypeName = appUser.AudienceOrg.AudienceType1.TypeOfAudience,
                            AudienceOrgId    = appUser.AudienceOrg.AudienceOrgID,
                            AudienceOrgName  = appUser.AudienceOrg.AudOrg
                        };
                        checkProfileResponse.SelectedAudienceType = new AudienceType()
                        {
                            AudienceTypeName = appUser.AudienceOrg.AudienceType1.TypeOfAudience,
                            AudienceTypeId   = appUser.AudienceOrg.AudienceType1.AudienceTypeID
                        };

                        foreach (var tech in appUser.TechnologyTags)
                        {
                            var PrimaryTech =
                                checkProfileResponse.SecondaryTechnologies.FirstOrDefault(
                                    x => x.PrimaryTechnologyId == tech.PrimaryTechnologyID);

                            if (PrimaryTech != null)
                            {
                                PrimaryTech.IsSelected = true;
                            }
                        }
                    }
                }
                response = this.Request.CreateResponse(HttpStatusCode.OK, checkProfileResponse);
                response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now.AddSeconds(300));
            }
            catch (Exception ex)
            {
                HttpError myCustomError = new HttpError(ex.Message)
                {
                    { "IsSuccess", false }
                };
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, myCustomError));
            }
            return(response);
        }
        public async Task <bool> GetTechnologes()
        {
            if (NetworkHelper.IsNetworkAvailable() == false)
            {
                await MessageHelper.ShowMessage("You require an active network connection to internet for registration");

                this.ShowError = true;
                return(false);
            }

            try
            {
                this.OperationInProgress = true;

                // Fetch data about the existing user and assign it to view model.
                var checkProfileResponse = await ServiceProxy.CallService("api/CheckProfile", JsonConvert.SerializeObject(new CheckProfileRequest()
                {
                    AuthProvider       = this.AuthProvider,
                    AuthProviderUserId = this.AuthProviderUserId
                }));

                if (checkProfileResponse.IsSuccess)
                {
                    CheckProfileResponse authUserInfoResponse = JsonConvert.DeserializeObject <CheckProfileResponse>(checkProfileResponse.response);

                    this.AudienceTypes         = authUserInfoResponse.AudienceTypes;
                    this.AllAudienceOrgTypes   = authUserInfoResponse.AudienceOrgTypes;
                    this.SecondaryTechnologies = authUserInfoResponse.SecondaryTechnologies;
                    this.Cities = new ObservableCollection <City>(authUserInfoResponse.Cities);
                    if (this.Cities == null)
                    {
                        this.Cities = new ObservableCollection <City>();
                    }
                    else if (this.Cities.Count > 0)
                    {
                        this.City = this.Cities[0];
                    }

                    if (this.AudienceTypes == null)
                    {
                        this.AudienceTypes = new List <AudienceType>();
                    }
                    else if (this.AudienceTypes.Count > 0)
                    {
                        this.SelectedAudienceType = this.AudienceTypes[0];
                    }


                    if (this.AudienceOrgTypes == null)
                    {
                        this.AudienceTypes = new List <AudienceType>();
                    }
                    else if (this.AudienceOrgTypes.Count > 0)
                    {
                        this.SelectedAudienceOrgType = this.AudienceOrgTypes[0];
                    }



                    this.OnPropertyChanged("AudienceTypes");
                    this.OnPropertyChanged("SecondaryTechnologies");
                    this.OnPropertyChanged("Cities");

                    if (authUserInfoResponse.IsRegistered)  // check if user is exsting or not
                    {
                        this.FullName           = authUserInfoResponse.FullName;
                        this.Email              = authUserInfoResponse.Email;
                        this.AuthProvider       = authUserInfoResponse.AuthProvider;
                        this.AuthProviderUserId = authUserInfoResponse.AuthProviderUserId;
                        this.City                    = authUserInfoResponse.City;
                        this.Town                    = authUserInfoResponse.Town;
                        this.Location                = authUserInfoResponse.Location;
                        this.SelectedAudienceType    = authUserInfoResponse.SelectedAudienceType;
                        this.SelectedAudienceOrgType = authUserInfoResponse.SelectedAudienceOrgType;
                        this.DeviceId                = authUserInfoResponse.DeviceId;
                        this.UserId                  = authUserInfoResponse.UserId;

                        if (!string.IsNullOrEmpty(this.DeviceId))
                        {
                            this.PushEnabled = true;
                        }

                        await LocalStorage.SaveJsonToFile(this, "registration");

                        return(true);
                    }
                    else
                    {
                        await this.SetCity(await GeoLocationHelper.GetCity(this.Cities.ToList()));
                    }
                }
                //else
                //{
                //    // if fetch data : FAILED.
                //    //unable to register you... unable to save your profile...
                //}
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(false);
            }
            finally
            {
                this.OperationInProgress = false;
            }
            return(false);
        }