Exemple #1
0
        public async Task <InpowerResult> Delete <T>(string url)
        {
            InpowerResult resp = new InpowerResult {
                Status = 0, Message = "", Response = null
            };

            using (var client = new HttpClient(new NativeMessageHandler()))
            {
                client.BaseAddress = new Uri(GlobalConstant.BaseUrl);
                if (!string.IsNullOrEmpty(GlobalConstant.AccessToken))
                {
                    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + GlobalConstant.AccessToken);
                }

                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = client.DeleteAsync(client.BaseAddress + url).Result;
                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <InpowerResult>(content));
                }
                else
                {
                    var content = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <InpowerResult>(content));
                }
            }
        }
Exemple #2
0
        //public async Task<InpowerResult> getAllBooks()
        //{
        //    InpowerResult resp = null;
        //    try
        //    {

        //        resp = await _helper.Get<InpowerResult>(GlobalConstant.BookShelfUrls.getAllBooksUrl.ToString());
        //        return resp;
        //    }
        //    catch (Exception ex)
        //    {
        //        CrashReportService crashReport = new CrashReportService();
        //        CrashReportModel CR = new CrashReportModel();
        //        CR.Filename = "BookShelfService";
        //        CR.Eventname = "GetAllBooks";
        //        // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
        //        CR.ErrorMsg = ex.Message + ex.StackTrace;
        //        await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);
        //        return resp;
        //    }
        //}

        public async Task <InpowerResult> GetAllBooks(PaginationModel paginationModel)
        {
            BooksMapViewModel model = new BooksMapViewModel();

            model.IsRead      = paginationModel.Status;
            model.SkipRecords = paginationModel.SkipRecords;
            model.TakeRecords = paginationModel.TakeRecords;
            model.SearchText  = (String.IsNullOrEmpty(paginationModel.SearchText)?"": paginationModel.SearchText);
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Post <BooksMapViewModel>(model, GlobalConstant.BookShelfUrls.getAllBooksUrl.ToString());

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "BookShelfService";
                CR.Eventname = "PostBook";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Exemple #3
0
        public async void PostUpdateAndroidToken(AndroidTokenViewModel model)
        {
            InpowerResult resp = null;

            try
            {
                await _helper.Post <AndroidTokenViewModel>(model, GlobalConstant.CommonUrls.PostAndroidTokenServiceUrl);
            }
            catch (Exception ex)
            {
            }
        }
Exemple #4
0
        public async Task <InpowerResult> Post <T>(T obj, string url)
        {
            InpowerResult resp = new InpowerResult {
                Status = 0, Message = "", Response = null
            };

            using (var client = new HttpClient(new NativeMessageHandler()))
            {
                client.BaseAddress = new Uri(GlobalConstant.BaseUrl);

                var json        = JsonConvert.SerializeObject(obj);
                var sendContent = new StringContent(json, Encoding.UTF8, "application/json");
                if (!string.IsNullOrEmpty(GlobalConstant.AccessToken))
                {
                    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + GlobalConstant.AccessToken);
                }
                else
                {
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                }


                HttpResponseMessage response = new HttpResponseMessage();
                try
                {
                    response = await client.PostAsync(client.BaseAddress + url, sendContent);
                }
                catch (Exception ex)
                {
                    resp.Message = ex.Message;
                }

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

                    return(JsonConvert.DeserializeObject <InpowerResult>(content));
                }
                else
                {
                    var content = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <InpowerResult>(content));
                }
            }
        }
Exemple #5
0
        public async Task <InpowerResult> UpdateBook(BooksMapViewModel model)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Post <BooksMapViewModel>(model, GlobalConstant.BookShelfUrls.UpdateBookUrl.ToString());

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "BookShelfService";
                CR.Eventname = "PostBook";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Exemple #6
0
        public async Task <InpowerResult> PostGroupMessageService(GroupMessageRequestViewModel groupSend)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Post <GroupMessageRequestViewModel>(groupSend, GlobalConstant.GroupChatUrls.PostMessageGroupUrl.ToString());

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "Registration";
                CR.Eventname = "AccountService";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Exemple #7
0
        public async Task <InpowerResult> GetGroupMessagesUpto(long groupId, string unixTimeStamp)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Get <InpowerResult>(GlobalConstant.GroupChatUrls.GetGroupMessagesUptoUrl.ToString() + "?groupId=" + groupId + "&unixTicks=" + unixTimeStamp);

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "Registration";
                CR.Eventname = "AccountService";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Exemple #8
0
        public async Task <InpowerResult> PostSuggestInterest(SuggestedInterestsRequestViewModel model)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Post <SuggestedInterestsRequestViewModel>(model, GlobalConstant.CommonUrls.PostSuggestInterestServiceUrl);

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "Interst";
                CR.Eventname = "InetrestService";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Exemple #9
0
        public async Task <InpowerResult> getChatAll(UserRequestViewModel model)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Get <InpowerResult>(GlobalConstant.ChatUrls.getAllChatServiceUrl.ToString());

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "Registration";
                CR.Eventname = "AccountService";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
        public async Task <InpowerResult> PostUnBlockUserInterest(userdetails BlockUser)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Post(BlockUser, GlobalConstant.SettingUrls.postUnBlockUserUrl);

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "Interst";
                CR.Eventname = "InetrestService";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
        public async void UpdateProfileData()
        {
            InpowerResult Result = null;

            try
            {
                if (txtZipCode.Text != "")
                {
                    if (txtCity.Text != "")
                    {
                        if (txtState.Text != "")
                        {
                            if (txtCountry.Text != "")
                            {
                                if (txtAboutMe.Text != "")
                                {
                                    if (CrossConnectivity.Current.IsConnected)
                                    {
                                        BTProgressHUD.Show("Please Wait", maskType: ProgressHUD.MaskType.Black);

                                        var UserprofileRepo = UserProfileRepository.GetUserProfile(CommonHelper.GetUserId());

                                        Result = await new AccountService().Registration(new UserRegisterRequestViewModel
                                        {
                                            Email    = UserprofileRepo.Email,
                                            Password = UserprofileRepo.Password,

                                            ZipCode = Convert.ToInt32(txtZipCode.Text),
                                            City    = txtCity.Text,
                                            State   = txtState.Text,
                                            Country = txtCountry.Text,
                                            AboutMe = txtAboutMe.Text,
                                        }, GlobalConstant.AccountUrls.RegisterServiceUrl);

                                        if (Result.Status == 1)
                                        {
                                            var modelReporeg = JsonConvert.DeserializeObject <UserRegisterResponseViewModel>(Result.Response.ToString());
                                            if (!string.IsNullOrEmpty(filePath))
                                            {
                                                uploadMedia(filePath, mediaType, modelReporeg);
                                            }
                                            else
                                            {
                                                UserprofileRepo.ZipCode = modelReporeg.ZipCode;
                                                UserprofileRepo.City    = modelReporeg.City;
                                                UserprofileRepo.State   = modelReporeg.State;
                                                UserprofileRepo.Country = modelReporeg.Country;

                                                UserprofileRepo.AboutMe         = modelReporeg.AboutMe;
                                                UserprofileRepo.ProfileImageUrl = modelReporeg.ProfileImageUrl;



                                                UserProfileRepository.UpdateUserProfile(UserprofileRepo);
                                                new UIAlertView("Update Your Profile", "Profile Updated Successfully", null, "OK", null).Show();

                                                BTProgressHUD.Dismiss();
                                                this.DismissViewController(true, null);
                                            }
                                        }
                                        else
                                        {
                                            BTProgressHUD.Dismiss();
                                            new UIAlertView("Update Your Profile", Result.Message, null, "OK", null).Show();
                                            return;
                                        }
                                    }

                                    else
                                    {
                                        new UIAlertView("Update Your Profile", "You're not connected to a Network", null, "OK", null).Show();
                                        return;
                                    }
                                }
                                else
                                {
                                    txtAboutMe.BecomeFirstResponder();
                                    new UIAlertView("Update Your Profile", "Please Enter About Me First", null, "OK", null).Show();
                                }
                            }
                            else
                            {
                                txtCountry.BecomeFirstResponder();
                                new UIAlertView("Update Your Profile", "Please Enter Country First", null, "OK", null).Show();
                            }
                        }
                        else
                        {
                            txtState.BecomeFirstResponder();
                            new UIAlertView("Update Your Profile", "Please Enter State First", null, "OK", null).Show();
                        }
                    }
                    else
                    {
                        txtCity.BecomeFirstResponder();
                        new UIAlertView("Update Your Profile", "Please Enter City First", null, "OK", null).Show();
                    }
                }
                else
                {
                    txtZipCode.BecomeFirstResponder();
                    new UIAlertView("Update Your Profile", "Please Enter Zip Code First", null, "OK", null).Show();
                }
            }
            catch (Exception ex)
            {
                BTProgressHUD.Dismiss();
                Crashes.TrackError(ex);
                string ErrorMsg = ex.ToString();
                new UIAlertView("Error", ErrorMsg, null, "OK", null).Show();
            }
        }
Exemple #12
0
        public async void UpdateProfileData()
        {
            InpowerResult Result = null;

            try
            {
                Drawable icon_error = Resources.GetDrawable(Resource.Drawable.alert);
                icon_error.SetBounds(0, 0, 50, 50);

                if (txtZipCode.Text != "")
                {
                    if (txtCity.Text != "")
                    {
                        if (txtState.Text != "")
                        {
                            if (txtCountry.Text != "")
                            {
                                if (txtAboutMe.Text != "")
                                {
                                    CommonHelper.ShowProgressBar(this);
                                    var UserprofileRepo = UserProfileRepository.GetUserProfile(CommonHelper.GetUserId());

                                    Result = await new AccountService().Registration(new UserRegisterRequestViewModel
                                    {
                                        Email    = UserprofileRepo.Email,
                                        Password = UserprofileRepo.Password,

                                        ZipCode = Convert.ToInt32(txtZipCode.Text),
                                        City    = txtCity.Text,
                                        State   = txtState.Text,
                                        Country = txtCountry.Text,
                                        AboutMe = txtAboutMe.Text,
                                    }, GlobalConstant.AccountUrls.RegisterServiceUrl);

                                    if (Result.Status == 1)
                                    {
                                        var modelReporeg = JsonConvert.DeserializeObject <UserRegisterResponseViewModel>(Result.Response.ToString());
                                        if (!string.IsNullOrEmpty(filePath))
                                        {
                                            uploadMedia(filePath, mediaType, modelReporeg);
                                        }
                                        else
                                        {
                                            UserprofileRepo.ZipCode = modelReporeg.ZipCode;
                                            UserprofileRepo.City    = modelReporeg.City;
                                            UserprofileRepo.State   = modelReporeg.State;
                                            UserprofileRepo.Country = modelReporeg.Country;

                                            UserprofileRepo.AboutMe         = modelReporeg.AboutMe;
                                            UserprofileRepo.ProfileImageUrl = modelReporeg.ProfileImageUrl;



                                            UserProfileRepository.UpdateUserProfile(UserprofileRepo);
                                            Toast.MakeText(this, "Profile Complete Successfully", ToastLength.Short).Show();
                                            CommonHelper.DismissProgressBar(this);
                                            this.Finish();
                                            var intent = new Intent(this, typeof(MainActivity));
                                            intent.AddFlags(ActivityFlags.SingleTop);

                                            StartActivity(intent);
                                        }
                                    }

                                    else
                                    {
                                        progressDialog.Hide();
                                        Toast.MakeText(this, Result.Message, ToastLength.Short).Show();
                                        return;
                                    }
                                }
                                else
                                {
                                    txtAboutMe.RequestFocus();
                                    txtAboutMe.SetError("Please Enter About Me First", icon_error);
                                }
                            }
                            else
                            {
                                txtCountry.RequestFocus();
                                txtCountry.SetError("Please Enter Country First", icon_error);
                            }
                        }
                        else
                        {
                            txtState.RequestFocus();
                            txtState.SetError("Please Enter State First", icon_error);
                        }
                    }
                    else
                    {
                        txtCity.RequestFocus();
                        txtCity.SetError("Please Enter City First", icon_error);
                    }
                }
                else
                {
                    txtZipCode.RequestFocus();
                    txtZipCode.SetError("Please Enter Zip Code First", icon_error);
                }
            }
            catch (Exception ex)
            {
                CommonHelper.DismissProgressBar(this);

                string ErrorMsg = ex.ToString();
                Toast.MakeText(this, ErrorMsg, ToastLength.Long).Show();
            }
        }
Exemple #13
0
        async public void BBIContinue_Activated()
        {
            InpowerResult Result = null;

            try
            {
                //Drawable icon_error = Resources.GetDrawable(Resource.Drawable.alert);
                //icon_error.SetBounds(0, 0, 50, 50);

                if (txtFirstName.Text != "")
                {
                    if (txtLastName.Text != "")
                    {
                        if (txtEmailAddress.Text != "")
                        {
                            if (txtPassword.Text != "")
                            {
                                if (txtConfirmPassword.Text != "")
                                {
                                    if (txtConfirmPassword.Text.Equals(txtConfirmPassword.Text))
                                    {
                                        if (CrossConnectivity.Current.IsConnected)
                                        {
                                            BTProgressHUD.Show("Please Wait", maskType: ProgressHUD.MaskType.Black);
                                            Result = await new AccountService().Registration(new UserRegisterRequestViewModel
                                            {
                                                Email    = txtEmailAddress.Text,
                                                Password = txtPassword.Text,

                                                FirstName = txtFirstName.Text,
                                                LastName  = txtLastName.Text
                                            }, GlobalConstant.AccountUrls.RegisterServiceUrl);

                                            if (Result.Status == 1)

                                            {
                                                var modelReporeg = JsonConvert.DeserializeObject <UserRegisterResponseViewModel>(Result.Response.ToString());
                                                var ResultToken  = await new AccountService().AccessToken(new TokenRequestViewModel
                                                {
                                                    UserName   = modelReporeg.Email,
                                                    password   = modelReporeg.Password,
                                                    grant_type = "password"
                                                });

                                                if (ResultToken != null)
                                                {
                                                    var profile = new UserProfile
                                                    {
                                                        UserId      = modelReporeg.UserId,
                                                        Email       = modelReporeg.Email,
                                                        FirstName   = modelReporeg.FirstName,
                                                        LastName    = modelReporeg.LastName,
                                                        Password    = modelReporeg.Password,
                                                        AccessToken = ResultToken.access_token,
                                                        isActive    = modelReporeg.isActive,
                                                        isShoutout  = modelReporeg.isShoutout
                                                    };
                                                    UserProfileRepository.SaveUserProfile(profile);
                                                    CommonHelper.SetUserPreferences(modelReporeg.UserId.ToString(), modelReporeg.Password, ResultToken.access_token, modelReporeg.Email, modelReporeg.AWSAccessKey, modelReporeg.AWSSecretKey);
                                                    GlobalConstant.AccessToken = ResultToken.access_token;
                                                    new UIAlertView("About You", Result.Message, null, "OK", null).Show();
                                                    clearAll();

                                                    BTProgressHUD.Dismiss();
                                                    //this.DismissViewController(true, null);
                                                    InvokeOnMainThread(delegate
                                                    {
                                                        UIStoryboard storyboard = this.Storyboard;
                                                        PleaseComplateYourProfileTableViewController viewController = (PleaseComplateYourProfileTableViewController)
                                                                                                                      storyboard.InstantiateViewController("PleaseComplateYourProfileTableViewController");
                                                        this.NavigationController.PushViewController(viewController, true);
                                                    });
                                                }
                                            }

                                            else
                                            {
                                                BTProgressHUD.Dismiss();

                                                new UIAlertView("About You", Result.Message, null, "OK", null).Show();
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            new UIAlertView("About You", "You're not connected to a Network", null, "OK", null).Show();
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        txtConfirmPassword.BecomeFirstResponder();
                                        new UIAlertView("About You", "Password Not Match", null, "OK", null).Show();
                                        return;
                                    }
                                }
                                else
                                {
                                    txtConfirmPassword.BecomeFirstResponder();
                                    new UIAlertView("About You", "Please Enter Confirm Password First", null, "OK", null).Show();
                                    return;
                                }
                            }
                            else
                            {
                                txtPassword.BecomeFirstResponder();
                                new UIAlertView("About You", "Please Enter Password First", null, "OK", null).Show();
                                return;
                            }
                        }
                        else
                        {
                            txtEmailAddress.BecomeFirstResponder();
                            new UIAlertView("About You", "Please Enter Email Address First", null, "OK", null).Show();
                            return;
                        }
                    }
                    else
                    {
                        txtLastName.BecomeFirstResponder();
                        new UIAlertView("About You", "Please Enter Last Name First", null, "OK", null).Show();
                        return;
                    }
                }
                else
                {
                    txtFirstName.BecomeFirstResponder();
                    new UIAlertView("About You", "Please Enter First Name First", null, "OK", null).Show();
                    return;
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                BTProgressHUD.Dismiss();
                string ErrorMsg = ex.ToString();
                new UIAlertView("Error", ErrorMsg, null, "OK", null).Show();
                return;
            }
        }
Exemple #14
0
        private async void BtnLogInWithEmail_Click(object sender, System.EventArgs e)
        {
            InpowerResult Result     = null;
            Drawable      icon_error = Resources.GetDrawable(Resource.Drawable.alert);

            icon_error.SetBounds(0, 0, 50, 50);
            try
            {
                if (txtLoginUserName.Text != "")
                {
                    if (txtLoginUserPassword.Text != "")
                    {
                        if (CrossConnectivity.Current.IsConnected)
                        {
                            CommonHelper.ShowProgressBar(this);

                            Result = await new AccountService().Login(new UserLoginRequestViewModel
                            {
                                Email        = txtLoginUserName.Text,
                                Password     = txtLoginUserPassword.Text,
                                AndroidToken = InstanceToken
                            }, GlobalConstant.AccountUrls.LoginServiceUrl);
                            if (Result != null)
                            {
                                if (Result.Status == 1)
                                {
                                    var modelReporeg = JsonConvert.DeserializeObject <UserRegisterResponseViewModel>(Result.Response.ToString());
                                    var ResultToken  = await new AccountService().AccessToken(new TokenRequestViewModel
                                    {
                                        UserName   = modelReporeg.Email,
                                        password   = modelReporeg.Password,
                                        grant_type = "password"
                                    });
                                    if (ResultToken != null)
                                    {
                                        var profile = new UserProfile
                                        {
                                            UserId          = modelReporeg.UserId,
                                            Email           = modelReporeg.Email,
                                            FirstName       = modelReporeg.FirstName,
                                            LastName        = modelReporeg.LastName,
                                            Password        = modelReporeg.Password,
                                            ZipCode         = modelReporeg.ZipCode,
                                            City            = modelReporeg.City,
                                            State           = modelReporeg.State,
                                            Country         = modelReporeg.Country,
                                            ProfileImageUrl = modelReporeg.ProfileImageUrl,
                                            AboutMe         = modelReporeg.AboutMe,
                                            AccessToken     = ResultToken.access_token,
                                            isActive        = modelReporeg.isActive,
                                            isShoutout      = modelReporeg.isShoutout,
                                            AndroidToken    = InstanceToken
                                        };


                                        UserProfileRepository.SaveUserProfile(profile);
                                        CommonHelper.SetUserPreferences(modelReporeg.UserId.ToString(), modelReporeg.Password.ToString(), ResultToken.access_token, modelReporeg.Email, modelReporeg.AWSAccessKey,
                                                                        modelReporeg.AWSSecretKey, null, null);
                                        GlobalConstant.AccessToken = ResultToken.access_token;
                                        CommonHelper.DismissProgressBar(this);
                                        this.Finish();
                                        StartActivity(typeof(MainActivity));
                                    }
                                }
                                else
                                {
                                    CommonHelper.DismissProgressBar(this);
                                    Toast.MakeText(this, Result.Message, ToastLength.Short).Show();
                                    return;
                                }
                            }
                        }
                        else
                        {
                            Toast.MakeText(this, "You're not connected to a Network", ToastLength.Short).Show();
                            return;
                        }
                    }
                    else
                    {
                        txtLoginUserPassword.RequestFocus();
                        txtLoginUserPassword.SetError("Password is not blank ", icon_error);
                    }
                }
                else
                {
                    txtLoginUserName.RequestFocus();
                    txtLoginUserName.SetError("Email Id is not blank ", icon_error);
                }
            }
            catch (Exception ex)
            {
                CommonHelper.DismissProgressBar(this);
            }
        }
Exemple #15
0
        private async void BtnContinue_Click(object sender, EventArgs e)
        {
            string inputemail    = txtEmailAddress.Text.ToString();
            var    emailvalidate = isValidEmail(inputemail);

            InpowerResult Result = null;

            try
            {
                Drawable icon_error = Resources.GetDrawable(Resource.Drawable.alert);
                icon_error.SetBounds(0, 0, 50, 50);

                if (txtFirstName.Text != "")
                {
                    if (txtLastName.Text != "")
                    {
                        if (txtEmailAddress.Text != "")
                        {
                            if (emailvalidate == true)
                            {
                                if (txtPassword.Text != "")
                                {
                                    if (txtConfirmPassword.Text != "")
                                    {
                                        if (txtConfirmPassword.Text == txtPassword.Text)
                                        {
                                            if (CrossConnectivity.Current.IsConnected)
                                            {
                                                CommonHelper.ShowProgressBar(this);
                                                Result = await new AccountService().Registration(new UserRegisterRequestViewModel
                                                {
                                                    Email    = txtEmailAddress.Text,
                                                    Password = txtPassword.Text,

                                                    FirstName = txtFirstName.Text,
                                                    LastName  = txtLastName.Text
                                                }, GlobalConstant.AccountUrls.RegisterServiceUrl);

                                                if (Result.Status == 1)

                                                {
                                                    var modelReporeg = JsonConvert.DeserializeObject <UserRegisterResponseViewModel>(Result.Response.ToString());
                                                    var ResultToken  = await new AccountService().AccessToken(new TokenRequestViewModel
                                                    {
                                                        UserName   = modelReporeg.Email,
                                                        password   = modelReporeg.Password,
                                                        grant_type = "password"
                                                    });

                                                    if (ResultToken != null)
                                                    {
                                                        var profile = new UserProfile
                                                        {
                                                            UserId      = modelReporeg.UserId,
                                                            Email       = modelReporeg.Email,
                                                            FirstName   = modelReporeg.FirstName,
                                                            LastName    = modelReporeg.LastName,
                                                            Password    = modelReporeg.Password,
                                                            AccessToken = ResultToken.access_token,
                                                            isActive    = modelReporeg.isActive,
                                                            isShoutout  = modelReporeg.isShoutout
                                                        };
                                                        UserProfileRepository.SaveUserProfile(profile);
                                                        CommonHelper.SetUserPreferences(modelReporeg.UserId.ToString(), modelReporeg.Password.ToLower(), ResultToken.access_token, modelReporeg.Email, modelReporeg.AWSAccessKey,
                                                                                        modelReporeg.AWSSecretKey, null, null);
                                                        GlobalConstant.AccessToken = ResultToken.access_token;
                                                        Toast.MakeText(this, Result.Message, ToastLength.Short).Show();
                                                        clearAll();
                                                        CommonHelper.DismissProgressBar(this);
                                                        this.Finish();

                                                        var intent = new Intent(this, typeof(ComplateYourProfileActivity));
                                                        intent.AddFlags(ActivityFlags.SingleTop);

                                                        StartActivity(intent);
                                                    }
                                                }

                                                else
                                                {
                                                    CommonHelper.DismissProgressBar(this);
                                                    Toast.MakeText(this, Result.Message, ToastLength.Short).Show();
                                                    return;
                                                }
                                            }
                                            else
                                            {
                                                Toast.MakeText(this, "You're not connected to a Network", ToastLength.Short).Show();
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            txtConfirmPassword.RequestFocus();
                                            txtConfirmPassword.SetError("Password Not Match", icon_error);
                                        }
                                    }
                                    else
                                    {
                                        txtConfirmPassword.RequestFocus();
                                        txtConfirmPassword.SetError("Please Enter Confirm Password First", icon_error);
                                    }
                                }
                                else
                                {
                                    txtPassword.RequestFocus();
                                    txtPassword.SetError("Please Enter Password First", icon_error);
                                }
                            }
                            else
                            {
                                txtEmailAddress.RequestFocus();
                                txtEmailAddress.SetError("Email is Not Valid", icon_error);
                            }
                        }
                        else
                        {
                            txtEmailAddress.RequestFocus();
                            txtEmailAddress.SetError("Please Enter Email Address First", icon_error);
                        }
                    }
                    else
                    {
                        txtLastName.RequestFocus();
                        txtLastName.SetError("Please Enter Last Name First", icon_error);
                    }
                }
                else
                {
                    txtFirstName.RequestFocus();
                    txtFirstName.SetError("Please Enter First Name First", icon_error);
                }
            }
            catch (Exception ex)
            {
                CommonHelper.DismissProgressBar(this);
                string ErrorMsg = ex.ToString();
                Toast.MakeText(this, ErrorMsg, ToastLength.Long).Show();
            }
        }
        private async void LoginProcess()
        {
            var token =Messaging.SharedInstance.FcmToken;
            try
            {
                InpowerResult Result = null;
                if (ValidateData())
                {
                    BTProgressHUD.Show("LogIn", maskType: ProgressHUD.MaskType.Black);
                    Result = await new AccountService().Login(new UserLoginRequestViewModel
                    {
                        Email = txt_UserName.Text,
                        Password = txtPassword.Text,
                        IOSToken = token
                    }, CommonConstant.AccountUrls.LoginServiceUrl);

                    if (Result != null)
                    {
                        if (Result.Status == 1)
                        {
                            var modelReporeg = JsonConvert.DeserializeObject<UserRegisterResponseViewModel>(Result.Response.ToString());
                            var ResultToken = await new AccountService().AccessToken(new TokenRequestViewModel
                            {
                                UserName = modelReporeg.Email,
                                password = modelReporeg.Password,
                                grant_type = "password"

                            });
                            if (ResultToken != null)
                            {
                                var profile = new UserProfile
                                {
                                    UserId = modelReporeg.UserId,
                                    Email = modelReporeg.Email,
                                    FirstName = modelReporeg.FirstName,
                                    LastName = modelReporeg.LastName,
                                    Password = modelReporeg.Password,
                                    ZipCode = modelReporeg.ZipCode,
                                    City = modelReporeg.City,
                                    State = modelReporeg.State,
                                    Country = modelReporeg.Country,
                                    ProfileImageUrl = modelReporeg.ProfileImageUrl,
                                    AboutMe = modelReporeg.AboutMe,
                                    AccessToken = ResultToken.access_token,
                                    isActive = modelReporeg.isActive,
                                    isShoutout = modelReporeg.isShoutout


                                };
                                UserProfileRepository.SaveUserProfile(profile);
;
                                ContinuetoMainScreen(modelReporeg.UserId.ToString(), modelReporeg.Password, ResultToken.access_token, modelReporeg.Email, modelReporeg.AWSAccessKey,
                                               modelReporeg.AWSSecretKey);


                            }

                        }
                        else
                        {
                            BTProgressHUD.Dismiss();
                            new UIAlertView("LogIn", Result.Message, null, "OK", null).Show();
                            return;
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                BTProgressHUD.Dismiss();
            }
           
        }
 #endregion LogIn with Email

        public void FacebookLoginProcess(LoginButtonCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Console.WriteLine(e.Error.ToString());
                new UIAlertView("Facebook",
                    "We were not able to authenticate you with Facebook. Please login again.", null, "OK", null)
                    .Show();
            }
            else if (e.Result.IsCancelled)
            {
                Console.WriteLine("Result was cancelled");
                new UIAlertView("Facebook", "You cancelled the Facebook login process. Please login again.", null,
                    "OK", null).Show();
            }
            else if (!e.Result.GrantedPermissions.ToString().Contains("email"))
            {
                // Check that we have email as a permission, otherwise show that we can't signup
                Console.WriteLine("Email permission not found");
                new UIAlertView("Facebook", "Email permission is required to sign in, Please login again.", null,
                    "OK", null).Show();

            }
            else
            {


                var meRequest = new GraphRequest("/me", new NSDictionary("fields", "first_name,last_name,name,email,picture"), "GET");
                var requestConnection = new GraphRequestConnection();
                requestConnection.AddRequest(meRequest, (connection, meResult, meError) =>
                {
                    var client = new WebClient();
                    if (meError != null)
                    {
                        Console.WriteLine(meError.ToString());
                        new UIAlertView("Facebook", "Unable to login to facebook.", null, "OK", null).Show();
                        return;
                    }

                    var user = meResult as NSDictionary;
                    var sc = new SocialLoginData();
                    sc.scFirstName = user.ValueForKey(new NSString("first_name")).Description;
                    sc.scLastName = user.ValueForKey(new NSString("last_name")).Description;
                    sc.scUserName = user.ValueForKey(new NSString("name")).Description;
                    sc.scSocialId = user.ValueForKey(new NSString("id")).Description;
                    sc.scEmail = user.ValueForKey(new NSString("email")).Description;
                    sc.scProfileImgUrl = ""; //user.ValueForKey(new NSString("picture")).Description;
                    sc.scSource = "facebook";
                    sc.scAccessUrl = "http://facebook.com/profile.php?id=" +
                                     user.ValueForKey(new NSString("id")).Description;
                    sc.scSocialOauthToken = AccessToken.CurrentAccessToken.TokenString;
                    sc.scAccount = AccessToken.CurrentAccessToken.TokenString;
               

                    StartRegistration(sc);
                });
                requestConnection.Start();

            }
        }


        public async void StartRegistration(SocialLoginData SocialData)
        {
            InpowerResult Result = null;
            UserProfile userProfile = new UserProfile();
            try
            {
                string  isscEmail = "";
                if (SocialData.scEmail != "" || SocialData.scEmail != null) { isscEmail = SocialData.scEmail; }else{isscEmail = SocialData.scFirstName + SocialData.scLastName + SocialData.scSocialId + "@InPower.com";}
                Result = await new AccountService().Registration(new UserRegisterRequestViewModel

                {
                    FirstName = SocialData.scFirstName,
                    LastName = SocialData.scLastName,
                    Email = isscEmail ,
                    Password = "******"
                }, GlobalConstant.AccountUrls.RegisterServiceUrl);

               

                var modelReporeg = JsonConvert.DeserializeObject<UserRegisterResponseViewModel>(Result.Response.ToString());
                var ResultToken = await new AccountService().AccessToken(new TokenRequestViewModel
                {
                    UserName = modelReporeg.Email,
                    password = modelReporeg.Password,
                    grant_type = "password"

                });

                if (Result.Message == "Detail Successfully Updated")
                {
                    ContinuetoMainScreen(modelReporeg.UserId.ToString(), modelReporeg.Password, ResultToken.access_token, modelReporeg.Email, modelReporeg.AWSAccessKey,modelReporeg.AWSSecretKey);
                }
                else
                {

                    var token = AccessToken.CurrentAccessToken != null;
                if (ResultToken != null)
                {
                                  
                 userProfile = new UserProfile
                 {
                     ProfileImageUrl = "",//respose.JSONObject.GetJSONObject("picture").GetJSONObject("data").GetString("url"),

                                    UserId = modelReporeg.UserId,
                                    FirstName = modelReporeg.FirstName,
                                    LastName = modelReporeg.LastName,
                            Email = modelReporeg.Email,
                                    Password = modelReporeg.Password,
                                    AccessToken = ResultToken.access_token,
                                    isActive = modelReporeg.isActive,
                                    isShoutout = modelReporeg.isShoutout
                                };

                                //var pictureUrl = respose.JSONObject.GetJSONObject("picture").GetJSONObject("data").GetString("url");
                                //var pictureData = client.DownloadData(pictureUrl);




                                UserProfileRepository.SaveUserProfile(userProfile);
                        CommonHelper.SetUserPreferences(modelReporeg.UserId.ToString(), modelReporeg.Password.ToLower(), ResultToken.access_token, modelReporeg.Email, modelReporeg.AWSAccessKey,
                                 modelReporeg.AWSSecretKey);
                                GlobalConstant.AccessToken = ResultToken.access_token;
                        new UIAlertView("Facebook Login", Result.Message, null, "OK", null).Show();
                        this.DismissViewController(true,null);
                                
                        InvokeOnMainThread(delegate
                      {
                          UIStoryboard storyboard = this.Storyboard;
                   PleaseComplateYourProfileTableViewController viewController = (PleaseComplateYourProfileTableViewController)
                                storyboard.InstantiateViewController("PleaseComplateYourProfileTableViewController");
                            viewController.userProfile = userProfile;
                          this.PresentViewController(viewController, true, null);
                      });

                            }
                
                else
                {
                        new UIAlertView("Facebook Login", Result.Message, null, "OK", null).Show();
                        return;
                }
            }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                new UIAlertView("Facebook Login", ex.Message, null, "OK", null).Show();
                return;
            }
        }
Exemple #18
0
        public async Task StartRegistration(SocialLoginData SocialData)
        {
            InpowerResult Result = null;

            try
            {
                Result = await new AccountService().Registration(new UserRegisterRequestViewModel

                {
                    FirstName = SocialData.scFirstName,
                    LastName  = SocialData.scLastName,
                    Email     = SocialData.scFirstName + SocialData.scLastName + SocialData.scSocialId + "@InPower.com",
                    Password  = "******"
                }, GlobalConstant.AccountUrls.RegisterServiceUrl);



                var modelReporeg = JsonConvert.DeserializeObject <UserRegisterResponseViewModel>(Result.Response.ToString());
                var ResultToken  = await new AccountService().AccessToken(new TokenRequestViewModel
                {
                    UserName   = modelReporeg.Email,
                    password   = modelReporeg.Password,
                    grant_type = "password"
                });

                if (Result.Message == "Detail Successfully Updated")
                {
                    var token = AccessToken.CurrentAccessToken != null;
                    SocialData.scSocialOauthToken = AccessToken.CurrentAccessToken?.Token;
                    UserProfile loginUserDetails = UserProfileRepository.GetUserProfile(CommonHelper.GetUserId());
                    var         intent           = new Intent(this, typeof(MainActivity));
                    intent.AddFlags(ActivityFlags.SingleTop);
                    StartActivity(intent);
                    CommonHelper.SetUserPreferences(modelReporeg.UserId.ToString(), modelReporeg.Password.ToLower(), ResultToken.access_token, modelReporeg.Email, modelReporeg.AWSAccessKey,
                                                    modelReporeg.AWSSecretKey, null, null);
                    GlobalConstant.AccessToken = ResultToken.access_token;
                    this.Finish();
                }
                else
                {
                    var token = AccessToken.CurrentAccessToken != null;
                    if (ResultToken != null)
                    {
                        if (token)
                        {
                            SocialData.scSocialOauthToken = AccessToken.CurrentAccessToken?.Token;
                            UserProfile userProfile;



                            userProfile = new UserProfile
                            {
                                Email           = email ?? "",
                                ProfileImageUrl = facebookpicture ?? "",

                                UserId      = modelReporeg.UserId,
                                FirstName   = modelReporeg.FirstName,
                                LastName    = modelReporeg.LastName,
                                Password    = modelReporeg.Password,
                                AccessToken = ResultToken.access_token,
                                isActive    = modelReporeg.isActive,
                                isShoutout  = modelReporeg.isShoutout
                            };



                            UserProfileRepository.SaveUserProfile(userProfile);
                            CommonHelper.SetUserPreferences(modelReporeg.UserId.ToString(), modelReporeg.Password.ToLower(), ResultToken.access_token, userProfile.Email, modelReporeg.AWSAccessKey,
                                                            modelReporeg.AWSSecretKey, null, null);
                            GlobalConstant.AccessToken = ResultToken.access_token;
                            Toast.MakeText(this, Result.Message, ToastLength.Short).Show();

                            // CommonHelper.DismissProgressBar(this);
                            //  this.Finish();
                            //var UserprofileRepo = UserProfileRepository.GetUserProfile(CommonHelper.GetUserId());
                            //if (modelReporeg.UserId==)
                            this.Finish();
                            var intent = new Intent(this, typeof(ComplateYourProfileActivity));
                            intent.PutExtra("UserProfile", JsonConvert.SerializeObject(userProfile));
                            intent.AddFlags(ActivityFlags.SingleTop);
                            StartActivity(intent);
                        }
                    }

                    else
                    {
                        //  CommonHelper.DismissProgressBar(this);
                        Toast.MakeText(this, Result.Message, ToastLength.Short).Show();
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                //  CommonHelper.DismissProgressBar(this);
                string ErrorMsg = ex.ToString();
                Toast.MakeText(this, ErrorMsg, ToastLength.Long).Show();
            }
        }