Ejemplo n.º 1
0
        private async void UploadImageToDB()
        {
            try
            {
                await Navigation.PushPopupAsync(new LoadingPopPage());

                _objUploadProfileResponse = await _apiServices.UpdateUserProfileAsync(new Get_API_Url().UpdateUserProfileApi(_baseUrl), true, _objHeaderModel, _mediaFile);

                if (_objUploadProfileResponse.Response.StatusCode == 200)
                {
                    _objGetProfilePicResponseModel = await _apiServices.GetUserprofileAsync(new Get_API_Url().GetUserProfileApi(_baseUrlGetProfile), true, _objHeaderModel, _objGetProfilePicResponseModel);

                    if (_objGetProfilePicResponseModel.Response.StatusCode == 200)
                    {
                        Settings.ProfilePicture = _objGetProfilePicResponseModel.Response.ProfilePicture;
                        await App.NavigationPage.Navigation.PushAsync(new UserProfilePage());

                        //DependencyService.Get<IToast>().ShowToast(_objGetProfilePicResponseModel.Response.Message);
                    }
                    DependencyService.Get <IToast>().ShowToast(_objUploadProfileResponse.Response.message);
                    await Navigation.PopAllPopupAsync();
                }
                else
                {
                    DependencyService.Get <IToast>().ShowToast(_objUploadProfileResponse.Response.message);
                    await Navigation.PopAllPopupAsync();
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
Ejemplo n.º 2
0
 //public UploadConfirmation(UploadProfileBase64Req objUploadProfileBase64Req)
 public UploadConfirmation(MediaFile mediafile)
 {
     InitializeComponent();
     _objUploadProfileRequest       = new UploadProfileRequest();
     _objUploadProfileResponse      = new UploadProfileResponse();
     _objGetProfilePicResponseModel = new GetProfilePicResponseModel();
     _apiServices = new RestApi();
     _mediaFile   = mediafile;
     _baseUrl     = Settings.Url + Domain.UpdateUserProfileApiConstant;
     // _objUploadProfileBase64Req = objUploadProfileBase64Req;
     _objHeaderModel          = new HeaderModel();
     _objHeaderModel.OTPToken = Settings.TokenCode;
     _baseUrlGetProfile       = Settings.Url + Domain.GetUserProfileApiConstant;
 }
Ejemplo n.º 3
0
        public async Task <GetProfilePicResponseModel> GetUserprofileAsync(string uri, Boolean IsHeaderRequired, HeaderModel objHeaderModel, GetProfilePicResponseModel _objGetProfilePicResponseModel)
        {
            GetProfilePicResponseModel objGetProfilePicResponseModel;
            string s = JsonConvert.SerializeObject(_objGetProfilePicResponseModel);
            HttpResponseMessage response = null;

            using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json"))
            {
                if (IsHeaderRequired)
                {
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", objHeaderModel.OTPToken);
                }
                response = await client.PostAsync(uri, stringContent);


                if (response.IsSuccessStatusCode)
                {
                    var SucessResponse = await response.Content.ReadAsStringAsync();

                    objGetProfilePicResponseModel = JsonConvert.DeserializeObject <GetProfilePicResponseModel>(SucessResponse);
                    return(objGetProfilePicResponseModel);
                }
                else
                {
                    var ErrorResponse = await response.Content.ReadAsStringAsync();

                    objGetProfilePicResponseModel = JsonConvert.DeserializeObject <GetProfilePicResponseModel>(ErrorResponse);
                    return(objGetProfilePicResponseModel);
                }
            }
        }