public async Task <CustomerResponse> InsertUpdateGuest(string token)
        {
            sw.Start();
            CustomerResponse output = null;

            try
            {
                var uri      = new Uri(ServiceURL + "InsertUpdateguests/" + token + "/token/1");
                var content  = JsonConvert.SerializeObject(token);
                var cont     = new StringContent(content, System.Text.Encoding.UTF8, "application/json");
                var response = await client.GetStringAsync(uri).ConfigureAwait(false);

                output = JsonConvert.DeserializeObject <CustomerResponse>(response);
                CurrentUser.SaveGuestId(output.customer.CustomerID.ToString());
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
            sw.Stop();
            LoggingClass.LogServiceInfo("Service " + sw.Elapsed.TotalSeconds, "Guest Service");
            return(output);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            CheckInternetConnection();
            Stopwatch st = new Stopwatch();

            st.Start();
            //for direct login
            //CurrentUser.SaveUserName("Sumanth","3");
            //Preinfo("8902519310330");
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.LoginView);
            var TaskA = new System.Threading.Tasks.Task(() =>
            {
                BlobWrapper.DownloadImages(Convert.ToInt32(CurrentUser.getUserId()));
            });

            TaskA.Start();
            //checking user id's exist or not.
            if ((CurrentUser.getUserId() != null || CurrentUser.getUserId() != "0") && (CurrentUser.getUserId() != null))
            {
                IntoApp();
            }
            else if (CurrentUser.GetGuestId() != null || CurrentUser.getUserId() == "0")
            {
                IntoApp();
            }
            else
            {
                //if (CurrentUser.GetCardNumber() != null)
                //{
                //    Preinfo(CurrentUser.GetCardNumber());
                //}
                ImageButton BtnScanner    = FindViewById <ImageButton>(Resource.Id.btnScanner);
                Button      BtnGuestLogin = FindViewById <Button>(Resource.Id.btnGuestLogin);
                LoggingClass.LogInfo("Opened the app", screenid);
                BtnScanner.Click += async delegate
                {
                    try
                    {
                        MobileBarcodeScanner.Initialize(Application);
                        var scanner = new ZXing.Mobile.MobileBarcodeScanner();
                        scanner.UseCustomOverlay = false;
                        var result = await scanner.Scan();// "8902519310330";// "900497354894";//await scanner.Scan();

                        if (result != null)
                        {
                            LoggingClass.LogInfo("User Tried to login with " + result, screenid);
                            Preinfo(result.Text);
                            CurrentUser.SaveCardNumber(result.Text);
                            txtmail.Visibility = ViewStates.Gone;
                            Txtem.Visibility   = ViewStates.Gone;
                        }
                    }
                    catch (Exception exe)
                    {
                        LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                    }
                };

                BtnGuestLogin.Click += async delegate
                {
                    Intent intent = new Intent(this, typeof(Login));
                    ProgressIndicator.Show(this);
                    LoggingClass.LogInfo("User Tried to login with Guest Login ", screenid);
                    StartActivity(intent);
                    CustomerResponse csr = new CustomerResponse();
                    csr = await svc.InsertUpdateGuest("Didn't get the token");

                    CurrentUser.SaveGuestId(csr.customer.CustomerID.ToString());
                };
                TxtScanresult             = FindViewById <TextView>(Resource.Id.txtScanresult);
                Txtem                     = FindViewById <TextView>(Resource.Id.textV);
                BtnLogin                  = FindViewById <Button>(Resource.Id.btnLogin);
                txtmail                   = FindViewById <EditText>(Resource.Id.txtmail);
                BtnResend                 = FindViewById <Button>(Resource.Id.btnResend);
                update                    = FindViewById <Button>(Resource.Id.btnUpdateEmailclick);
                BtnContinue               = FindViewById <Button>(Resource.Id.btnContinue);
                BtnUpdateEmail            = FindViewById <Button>(Resource.Id.btnUpdateEmail);
                BtnResend.Visibility      = ViewStates.Gone;
                update.Visibility         = ViewStates.Gone;
                BtnLogin.Visibility       = ViewStates.Gone;
                BtnContinue.Visibility    = ViewStates.Gone;
                BtnUpdateEmail.Visibility = ViewStates.Gone;
                txtmail.Visibility        = ViewStates.Gone;
                Txtem.Visibility          = ViewStates.Gone;
                if (IsPlayServicesAvailable())
                {
                    var TaskB = new System.Threading.Tasks.Task(() =>
                    {
                        var intent = new Intent(this, typeof(RegistrationIntentService));
                        StartService(intent);
                    });
                    TaskB.Start();
                }
                var telephonyDeviceID             = string.Empty;
                var telephonySIMSerialNumber      = string.Empty;
                TelephonyManager telephonyManager = (TelephonyManager)this.ApplicationContext.GetSystemService(Context.TelephonyService);
                if (telephonyManager != null)
                {
                    if (!string.IsNullOrEmpty(telephonyManager.DeviceId))
                    {
                        telephonyDeviceID = telephonyManager.DeviceId;
                    }
                    if (!string.IsNullOrEmpty(telephonyManager.SimSerialNumber))
                    {
                        telephonySIMSerialNumber = telephonyManager.SimSerialNumber;
                    }
                }
                var androidID  = Android.Provider.Settings.Secure.GetString(this.ApplicationContext.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
                var deviceUuid = new UUID(androidID.GetHashCode(), ((long)telephonyDeviceID.GetHashCode() << 32) | telephonySIMSerialNumber.GetHashCode());
                var DeviceID   = deviceUuid.ToString();
                CurrentUser.SaveDeviceID(DeviceID);
                BtnScanner.Dispose();
            }
        }
Esempio n. 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.ProfileCell);
            int userId = Convert.ToInt32(CurrentUser.getUserId());

            ActionBar.SetHomeButtonEnabled(true);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ServiceWrapper sw     = new ServiceWrapper();
            var            output = sw.GetCustomerDetails(userId).Result;

            RefreshParent();
            if (CurrentUser.getUserId() == "0" || CurrentUser.getUserId() == null)
            {
                AlertDialog.Builder aler = new AlertDialog.Builder(this, Resource.Style.MyDialogTheme);
                aler.SetTitle("Sorry");
                aler.SetMessage("This feature is available only  for VIP Users");
                aler.SetPositiveButton("Log in", delegate
                {
                    string str = null;
                    CurrentUser.SaveGuestId(str);
                    var intent = new Intent(this, typeof(LoginActivity));
                    StartActivity(intent);
                });
                aler.SetNegativeButton("KnowMore", delegate
                {
                    var uri    = Android.Net.Uri.Parse("https://hangoutz.azurewebsites.net/index.html");
                    var intent = new Intent(Intent.ActionView, uri);
                    StartActivity(intent);
                });
                aler.SetNeutralButton("Cancel", delegate
                {
                    var intent = new Intent(this, typeof(Login));
                    StartActivity(intent);
                });
                Dialog dialog1 = aler.Create();
                dialog1.Show();
            }

            try
            {
                propicimage = FindViewById <ImageView>(Resource.Id.user_profile_photo);
                TextView  Name      = FindViewById <TextView>(Resource.Id.user_profile_name);
                TextView  Email     = FindViewById <TextView>(Resource.Id.user_profile_short_bio);
                TextView  Mobile    = FindViewById <TextView>(Resource.Id.user_mobile);
                TextView  Address   = FindViewById <TextView>(Resource.Id.user_Address);
                TextView  PinCode   = FindViewById <TextView>(Resource.Id.user_Zip);
                TextView  Preferrd  = FindViewById <TextView>(Resource.Id.user_Preferred);
                TextView  State     = FindViewById <TextView>(Resource.Id.user_State);
                TextView  Card      = FindViewById <TextView>(Resource.Id.user_Card);
                TextView  Expiry    = FindViewById <TextView>(Resource.Id.User_expiry);
                Button    Drop      = FindViewById <Button>(Resource.Id.drop_down_option_menu);
                ImageView ChangePRo = FindViewById <ImageView>(Resource.Id.add_friend);

                ChangePRo.Click += delegate
                {
                    AlertDialog.Builder aler = new AlertDialog.Builder(this, Resource.Style.MyDialogTheme);
                    aler.SetTitle("Please choose an option to upload profile picture");
                    aler.SetPositiveButton("Gallery", delegate
                    {
                        Intent = new Intent();
                        Intent.SetType("image/*");
                        Intent.SetAction(Intent.ActionGetContent);
                        StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId);
                    });

                    aler.SetNegativeButton("Camera", delegate
                    {
                        if (IsThereAnAppToTakePictures())
                        {
                            CreateDirectoryForPictures();
                            TakeAPicture();
                        }
                    });
                    aler.SetNeutralButton("Cancel", delegate
                    {
                    });
                    Dialog dialog1 = aler.Create();
                    dialog1.Show();
                };
                // Boolean indirect = true;
                if (indirect == true)
                {
                    System.Threading.Timer timer = null;
                    timer = new System.Threading.Timer((obj) =>
                    {
                        DownloadAsync(this, System.EventArgs.Empty);

                        timer.Dispose();
                    },
                                                       null, 2000, System.Threading.Timeout.Infinite);
                }
                else
                {
                    DownloadAsync(this, System.EventArgs.Empty);
                }
                Drop.Click += (s, arg) =>
                {
                    Intent intent = new Intent(this, typeof(ProfileActivity));
                    ProgressIndicator.Show(this);
                    StartActivity(intent);
                    //PopupMenu menu = new PopupMenu(this, Drop);
                    //menu.Inflate(Resource.Drawable.options_menu_1);
                    //menu.Show();
                };
                string First = output.customer.FirstName;
                string Last  = output.customer.LastName;
                Name.Text = string.Concat(First, Last);
                Card.Text = output.customer.CardNumber.ToString();

                Email.Text = output.customer.Email;

                PinCode.Text  = output.customer.Zip.ToString();
                Preferrd.Text = output.customer.PreferredStore.ToString();
                if (Preferrd.Text == "0")
                {
                    Preferrd.Text = "-Select your preferred store-";
                }
                else if (Preferrd.Text == "1")

                {
                    Preferrd.Text = AppConstants.WallStore;
                }
                else if (Preferrd.Text == "2")
                {
                    Preferrd.Text = AppConstants.PointPleasantStore;
                }
                else
                {
                    Preferrd.Text = AppConstants.SecaucusStore;
                }

                State.Text  = output.customer.State;
                Expiry.Text = output.customer.ExpireDate.ToString();
                string Addres2 = output.customer.Address2;
                string Addres1 = output.customer.Address1;
                Address.Text = string.Concat(Addres1, Addres2);
                string phno1 = output.customer.PhoneNumber;
                string phno2 = output.customer.Phone2;
                if (phno1 != null)
                {
                    Mobile.Text = phno1;
                }
                else
                {
                    Mobile.Text = phno2;
                }
            }
            catch (Exception exe)
            {
                LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
            }
            ProgressIndicator.Hide();
        }
Esempio n. 4
0
        protected override void OnCreate(Bundle bundle)
        {
            CheckInternetConnection();
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Profile);
            try
            {
                GC.Collect();
                LoggingClass.LogInfo("Entered into Profile Activity", screenid);
                ActionBar.SetHomeButtonEnabled(true);
                ActionBar.SetDisplayHomeAsUpEnabled(true);
                int            userId       = Convert.ToInt32(CurrentUser.getUserId());
                ServiceWrapper sw           = new ServiceWrapper();
                var            output       = sw.GetCustomerDetails(userId).Result;
                EditText       Firstname    = FindViewById <EditText>(Resource.Id.txtFirstName);
                Button         updatebtn    = FindViewById <Button>(Resource.Id.UpdateButton);
                Spinner        spn          = FindViewById <Spinner>(Resource.Id.spinner);
                Spinner        Prefered     = FindViewById <Spinner>(Resource.Id.spinner1);
                EditText       Mobilenumber = FindViewById <EditText>(Resource.Id.txtMobileNumber);
                EditText       Lastname     = FindViewById <EditText>(Resource.Id.txtLastName);
                EditText       Email        = FindViewById <EditText>(Resource.Id.txtEmail);
                EditText       Address      = FindViewById <EditText>(Resource.Id.txtAddress);
                EditText       PinCode      = FindViewById <EditText>(Resource.Id.txtZip);
                if (CurrentUser.getUserId() == "0" || CurrentUser.getUserId() == null)
                {
                    AlertDialog.Builder aler = new AlertDialog.Builder(this, Resource.Style.MyDialogTheme);
                    aler.SetTitle("Sorry");
                    aler.SetMessage("This feature is available only  for VIP Users");
                    aler.SetPositiveButton("Log in", delegate
                    {
                        string str = null;
                        CurrentUser.SaveGuestId(str);
                        var intent = new Intent(this, typeof(LoginActivity));
                        StartActivity(intent);
                    });
                    aler.SetNegativeButton("KnowMore", delegate
                    {
                        var uri    = Android.Net.Uri.Parse("https://hangoutz.azurewebsites.net/index.html");
                        var intent = new Intent(Intent.ActionView, uri);
                        StartActivity(intent);
                    });
                    aler.SetNeutralButton("Cancel", delegate
                    {
                        var intent = new Intent(this, typeof(Login));
                        StartActivity(intent);
                    });
                    Dialog dialog1 = aler.Create();
                    dialog1.Show();
                }
                else
                {
                    Firstname.Text = output.customer.FirstName;
                    Lastname.Text  = output.customer.LastName;
                    string phno1 = output.customer.PhoneNumber;
                    string phno2 = output.customer.Phone2;
                    if (phno1 != null)
                    {
                        Mobilenumber.Text = phno1;
                    }
                    else
                    {
                        Mobilenumber.Text = phno2;
                    }
                    Email.Text = output.customer.Email;
                    string Addres2 = output.customer.Address2;
                    string Addres1 = output.customer.Address1;
                    Address.Text = string.Concat(Addres1, Addres2);
                    PinCode.Text = output.customer.Zip;
                    string        state         = output.customer.State;
                    int           Preferedstore = output.customer.PreferredStore;
                    List <string> storelist     = new List <string>();
                    storelist.Add("--Select your preferred store--");
                    storelist.Add("Wall");
                    storelist.Add("Point Pleasant");
                    storelist.Add("Secaucus");
                    storelist.Add("All");
                    List <string> StateList = new List <string>();
                    StateList.Add("AL");
                    StateList.Add("AK");
                    StateList.Add("AZ");
                    StateList.Add("AR");
                    StateList.Add("CA");
                    StateList.Add("CO");
                    StateList.Add("CT");
                    StateList.Add("DE");
                    StateList.Add("FL");
                    StateList.Add("GA");
                    StateList.Add("HI");
                    StateList.Add("ID");
                    StateList.Add("IL");
                    StateList.Add("IN");
                    StateList.Add("IA");
                    StateList.Add("KS");
                    StateList.Add("KY");
                    StateList.Add("LA");
                    StateList.Add("ME");
                    StateList.Add("MD");
                    StateList.Add("MA");
                    StateList.Add("MI");
                    StateList.Add("MN");
                    StateList.Add("MS");
                    StateList.Add("MO");
                    StateList.Add("MT");
                    StateList.Add("NE");
                    StateList.Add("NV");
                    StateList.Add("NH");
                    StateList.Add("NJ");
                    StateList.Add("NM");
                    StateList.Add("NY");
                    StateList.Add("NC");
                    StateList.Add("ND");
                    StateList.Add("OH");
                    StateList.Add("OK");
                    StateList.Add("OR");
                    StateList.Add("PA");
                    StateList.Add("RI");
                    StateList.Add("SC");
                    StateList.Add("SD");
                    StateList.Add("TN");
                    StateList.Add("TX");
                    StateList.Add("UT");
                    StateList.Add("VT");
                    StateList.Add("VA");
                    StateList.Add("WA");
                    StateList.Add("WV");
                    StateList.Add("WI");
                    StateList.Add("WY");
                    try
                    {
                        int i = StateList.IndexOf(state.ToString());
                        spn.SetSelection(i);
                    }
                    catch { }
                    int p = storelist.IndexOf(Prefered.SelectedItem.ToString());
                    Prefered.SetSelection(Preferedstore);


                    updatebtn.Click += async delegate
                    {
                        if ((Email.Text.Contains("@")) == false || (Email.Text.Contains(".")) == false)
                        {
                            AndHUD.Shared.ShowErrorWithStatus(this, "Email is invalid", MaskType.Clear, TimeSpan.FromSeconds(2));
                        }
                        else if ((PinCode.Text.Length != 5))
                        {
                            AndHUD.Shared.ShowErrorWithStatus(this, "Zipcode is invalid", MaskType.Clear, TimeSpan.FromSeconds(2));
                        }
                        else if ((Mobilenumber.Text == "") || (Mobilenumber.Text.Length != 10))
                        {
                            AndHUD.Shared.ShowErrorWithStatus(this, "Enter valid mobile number", MaskType.Clear, TimeSpan.FromSeconds(2));
                        }
                        else
                        {
                            AndHUD.Shared.Show(this, "Please Wait...", Convert.ToInt32(MaskType.Clear));

                            Customer customer = new Customer()
                            {
                                FirstName      = Firstname.Text,
                                LastName       = Lastname.Text,
                                PhoneNumber    = Mobilenumber.Text,
                                Address1       = Address.Text,
                                Email          = Email.Text,
                                CustomerID     = userId,
                                State          = spn.SelectedItem.ToString(),
                                Zip            = PinCode.Text,
                                PreferredStore = Convert.ToInt32(Prefered.SelectedItemId)
                            };
                            CurrentUser.SavePrefered(Convert.ToInt32(Prefered.SelectedItemId));
                            LoggingClass.LogInfo("Clicked on update info", screenid);
                            var x = await sw.UpdateCustomer(customer);

                            if (x == 1)
                            {
                                var intent = new Intent(this, typeof(PotraitActivity));
                                StartActivity(intent);
                            }
                            AndHUD.Shared.Dismiss();
                            AndHUD.Shared.ShowSuccess(this, "Profile Updated", MaskType.Clear, TimeSpan.FromSeconds(2));
                        }
                    };
                    ProgressIndicator.Hide();
                    updatebtn.Dispose();
                }
            }
            catch (Exception exe)
            {
                LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
                AlertDialog.Builder aler = new AlertDialog.Builder(this);
                aler.SetTitle("Sorry");
                aler.SetMessage("We're under maintainence");
                aler.SetNegativeButton("Ok", delegate { });
                Dialog dialog = aler.Create();
                dialog.Show();
            }

            ProgressIndicator.Hide();
        }