public MyReviewCellView(NSString cellId) : base(UITableViewCellStyle.Default, cellId)
        {
            try
            {
                btnBack = new UIButton();
                btnBack.BackgroundColor        = UIColor.FromRGB(63, 63, 63);
                btnBack.UserInteractionEnabled = false;
                SelectionStyle             = UITableViewCellSelectionStyle.Gray;
                imageView                  = new UIButton();
                imageView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                imageView.ContentMode      = UIViewContentMode.Center;
                imageView.ClipsToBounds    = true;
                //imageView.TouchDown += (object sender, EventArgs e) =>
                //{
                //	BTProgressHUD.Show("Loading...");
                //};
                imageView.TouchUpInside += (object sender, EventArgs e) =>
                {
                    BTProgressHUD.Show(LoggingClass.txtloading);
                    NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false);
                };
                Review review = new Review();
                separator = new UIImageView();

                btnItemname = new UIButton();
                btnItemname.SetTitle("", UIControlState.Normal);
                btnItemname.SetTitleColor(UIColor.FromRGB(127, 51, 0), UIControlState.Normal);
                btnItemname.Font                = UIFont.FromName("Verdana-Bold", 13f);
                btnItemname.LineBreakMode       = UILineBreakMode.WordWrap;
                btnItemname.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
                btnItemname.TouchUpInside      += delegate
                {
                    BTProgressHUD.Show("Loading...");
                    NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false);
                };
                ReviewDate = new UILabel()
                {
                    Font      = UIFont.FromName("AmericanTypewriter", 10f),
                    TextColor = UIColor.FromRGB(38, 127, 200),
                    //TextAlignment = UITextAlignment.Center,
                    BackgroundColor = UIColor.Clear
                };
                Comments = new UITextView()
                {
                    Font          = UIFont.FromName("AmericanTypewriter", 14f),
                    TextColor     = UIColor.FromRGB(55, 127, 0),
                    TextAlignment = UITextAlignment.Justified,
                    //TextAlignment = UITextAlignment.Natural,
                    BackgroundColor = UIColor.Clear,
                    //LineBreakMode = UILineBreakMode.WordWrap
                    Editable   = false,
                    Selectable = false
                };
                ReadMore = new UIButton()
                {
                    Font            = UIFont.FromName("Verdana", 10f),
                    BackgroundColor = UIColor.White
                };
                Vintage = new UILabel()
                {
                    Font            = UIFont.FromName("Verdana", 10f),
                    TextColor       = UIColor.FromRGB(127, 51, 100),
                    BackgroundColor = UIColor.Clear
                };
                decimal averageRating = 0.0m;
                var     ratingConfig  = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/star-silver2.png"),
                                                         filledImage: UIImage.FromBundle("Stars/star.png"),
                                                         chosenImage: UIImage.FromBundle("Stars/star.png"));
                stars   = new PDRatingView(new CGRect(110, 60, 60, 20), ratingConfig, averageRating);
                btnEdit = new UIButton();
                btnEdit.SetImage(UIImage.FromFile("edit.png"), UIControlState.Normal);
                btnEdit.TouchUpInside += (sender, e) =>
                {
                    PopupView yourController = new PopupView(WineIdLabel.Text, storeid);
                    yourController.NavController  = NavController;
                    yourController.parent         = Parent;
                    yourController.StartsSelected = stars.AverageRating;
                    yourController.Comments       = Comments.Text;
                    LoggingClass.LogInfo("Edited the review of " + wineId, screenid);


                    //yourController.WineId = Convert.ToInt32(WineIdLabel.Text);
                    yourController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
                    //this.PresentViewController(yourController, true, null);
                    Parent.PresentModalViewController(yourController, false);
                };
                btnDelete = new UIButton();
                btnDelete.SetImage(UIImage.FromFile("delete.png"), UIControlState.Normal);
                btnDelete.TouchUpInside += (sender, e) =>
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "Delete Review ",
                        Message = LoggingClass.txtdeletereview,
                    };
                    alert.AddButton("Yes");
                    alert.AddButton("No");

                    alert.Clicked += async(senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 0)
                        {
                            review.Barcode      = WineIdLabel.Text;
                            review.ReviewUserId = Convert.ToInt32(CurrentUser.RetreiveUserId());
                            BTProgressHUD.Show("Deleting review");
                            await sw.DeleteReview(review);

                            LoggingClass.LogInfo("Deleting the review of " + wineId, screenid);
                            BTProgressHUD.ShowSuccessWithStatus("Done");
                            ((IPopupParent)Parent).RefreshParent();
                        }
                    };

                    alert.Show();
                };
                btnLike = new UIButton();
                btnLike.ClipsToBounds              = true;
                btnLike.Layer.BorderColor          = UIColor.White.CGColor;
                btnLike.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;
                btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                btnLike.Tag = 0;
                //myItem = new Item();
                //bool count =Convert.ToBoolean( myItem.IsLike);
                //if (count == true)
                //{
                //btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);}
                //else
                //{
                //	btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                //}
                btnLike.TouchUpInside += async(object sender, EventArgs e) =>
                {
                    try
                    {
                        UIButton temp = (UIButton)sender;
                        if (temp.Tag == 0)
                        {
                            btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                            temp.Tag   = 1;
                            Data.Liked = 1;
                            //btnLike.Tag = 1;
                            LoggingClass.LogInfo("Liked Wine " + WineIdLabel.Text, screenid);
                        }
                        else
                        {
                            btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                            temp.Tag   = 0;
                            Data.Liked = 0;

                            LoggingClass.LogInfo("Unliked Wine " + WineIdLabel.Text, screenid);
                        }
                        SKULike like = new SKULike();
                        like.UserID  = Convert.ToInt32(CurrentUser.RetreiveUserId());
                        like.BarCode = WineIdLabel.Text;
                        like.Liked   = Convert.ToBoolean(temp.Tag);

                        Data.Liked = Convert.ToInt32(temp.Tag);
                        await sw.InsertUpdateLike(like);
                    }
                    catch (Exception ex)
                    {
                        LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
                    }
                };
                WineIdLabel = new UILabel();
                ContentView.AddSubviews(new UIView[] { btnBack, btnItemname, ReadMore, ReviewDate, Comments, stars, imageView, Vintage, separator, btnEdit, btnDelete, btnLike });
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }
Пример #2
0
        public override void ViewDidLoad()
        {
            //AboutController1.ViewDidLoad(base);
            // Perform any additional setup after loading the view, typically from a nib.
            try
            {
                nfloat ScreenHeight = UIScreen.MainScreen.Bounds.Height;
                ScreenHeight = (ScreenHeight - 100) / 4;
                nfloat   margin        = 1;
                nfloat   start         = 50;
                UIButton btnReviews    = new UIButton();
                UIButton btnTastings   = new UIButton();
                UIButton btnFavourites = new UIButton();
                UIButton btnMyStore    = new UIButton();
                LoggingClass.LogInfo("Entered into My Hangouts", screen);
                btnReviews.Frame    = new CGRect(0, start + ScreenHeight + margin, UIScreen.MainScreen.Bounds.Width, ScreenHeight);
                btnTastings.Frame   = new CGRect(0, start, UIScreen.MainScreen.Bounds.Width, ScreenHeight);
                btnFavourites.Frame = new CGRect(0, start + (ScreenHeight + margin) * 2, UIScreen.MainScreen.Bounds.Width, ScreenHeight);
                btnMyStore.Frame    = new CGRect(0, start + ((ScreenHeight + margin) * 3) + 1, UIScreen.MainScreen.Bounds.Width, ScreenHeight);

                btnReviews.SetTitle("", UIControlState.Normal);
                btnMyStore.SetTitle("", UIControlState.Normal);
                btnTastings.SetTitle("", UIControlState.Normal);
                btnFavourites.SetTitle("", UIControlState.Normal);

                btnReviews.SetBackgroundImage(new UIImage("Images/mr.jpg"), UIControlState.Normal);
                btnTastings.SetBackgroundImage(new UIImage("Images/mt.jpg"), UIControlState.Normal);
                btnFavourites.SetBackgroundImage(new UIImage("Images/mf.jpg"), UIControlState.Normal);
                btnMyStore.SetBackgroundImage(new UIImage("Images/ms.jpg"), UIControlState.Normal);
                //if (CurrentUser.RetreiveUserId() == 0)
                //{
                //	UIAlertView alert1 = new UIAlertView()
                //	{
                //		Title = "This feature is allowed only for VIP Card holders",
                //		//Message = "Coming Soon..."
                //	};
                //	alert1.AddButton("OK");
                //	alert1.AddButton("Know more");
                //		alert1.Clicked += (senderalert, buttonArgs) =>
                //		{
                //			if (buttonArgs.ButtonIndex == 1)
                //			{
                //				UIApplication.SharedApplication.OpenUrl(new NSUrl("http://savvyitdev.com/winehangouts/"));
                //			}
                //		};
                //	alert1.AddButton("Login");
                //	alert1.Show();
                //	btnReviews.TouchUpInside += (sender, e) =>
                //	{
                //		UIAlertView alert = new UIAlertView()
                //		{
                //			Title = "This feature is allowed only for VIP Card holders",
                //				//Message = "Coming Soon..."
                //			};
                //		alert.AddButton("OK");
                //		alert.AddButton("Know more");
                //		alert.Clicked += (senderalert, buttonArgs) =>
                //		{
                //			if (buttonArgs.ButtonIndex == 1)
                //			{
                //				UIApplication.SharedApplication.OpenUrl(new NSUrl("http://savvyitdev.com/winehangouts/"));
                //			}
                //		};
                //		alert.Show();
                //	};
                //	btnTastings.TouchUpInside += (sender, e) =>
                //	{
                //		UIAlertView alert = new UIAlertView()
                //		{
                //			Title = "This feature is allowed only for VIP Card holders",
                //				//Message = "Coming Soon..."
                //			};
                //		alert.AddButton("OK");
                //		alert.AddButton("Know more");
                //		alert.Clicked += (senderalert, buttonArgs) =>
                //		{
                //			if (buttonArgs.ButtonIndex == 1)
                //			{
                //				UIApplication.SharedApplication.OpenUrl(new NSUrl("http://savvyitdev.com/winehangouts/"));
                //			}
                //		};
                //		alert.Show();
                //	};
                //	btnFavourites.TouchUpInside += (sender, e) =>
                //	{
                //		UIAlertView alert = new UIAlertView()
                //		{
                //			Title = "This feature is allowed only for VIP Card holders",
                //				//Message = "Coming Soon..."
                //			};
                //		alert.AddButton("OK");
                //		alert.AddButton("Know more");
                //		alert.Clicked += (senderalert, buttonArgs) =>
                //		{
                //			if (buttonArgs.ButtonIndex == 1)
                //			{
                //				UIApplication.SharedApplication.OpenUrl(new NSUrl("http://savvyitdev.com/winehangouts/"));
                //			}
                //		};
                //		alert.Show();
                //	};
                //}
                //else
                //{
                btnReviews.TouchDown += (sender, e) =>
                {
                    BTProgressHUD.Show("Loading...");                             //show spinner + text
                };
                btnTastings.TouchDown += (sender, e) =>
                {
                    BTProgressHUD.Show("Loading...");                             //show spinner + text
                };
                btnFavourites.TouchDown += (sender, e) =>
                {
                    BTProgressHUD.Show("Loading...");                             //show spinner + text
                };
                btnMyStore.TouchDown += (sender, e) =>
                {
                    BTProgressHUD.Show("Loading...");
                };
                btnReviews.TouchUpInside += (sender, e) =>
                {
                    if (CurrentUser.RetreiveUserId() != 0)
                    {
                        var MyReview = new MyReviewViewController();
                        NavigationController.PushViewController(MyReview, false);
                        LoggingClass.LogInfo("Entered into My Reviews", screen);
                        BTProgressHUD.Dismiss();
                        NavigationController.NavigationBar.TopItem.Title = "My Reviews";
                    }
                    else
                    {
                        BTProgressHUD.Dismiss();
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "This feature is allowed only for VIP Card holders",
                            //Message = "Coming Soon..."
                        };
                        alert.AddButton("OK");
                        alert.AddButton("Know more");
                        alert.Clicked += (senderalert, buttonArgs) =>
                        {
                            if (buttonArgs.ButtonIndex == 1)
                            {
                                UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                            }
                        };
                        alert.Show();
                    }
                };
                btnTastings.TouchUpInside += (sender, e) =>
                {
                    if (CurrentUser.RetreiveUserId() != 0)
                    {
                        var MyTaste = new MyTastingViewController();
                        NavigationController.PushViewController(MyTaste, false);
                        LoggingClass.LogInfo("Entered into My Tastings", screen);
                        BTProgressHUD.Dismiss();
                        NavigationController.NavigationBar.TopItem.Title = "My Tastings";
                    }
                    else
                    {
                        BTProgressHUD.Dismiss();
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "This feature is allowed only for VIP Card holders",
                            //Message = "Coming Soon..."
                        };
                        alert.AddButton("OK");
                        alert.AddButton("Know more");
                        alert.Clicked += (senderalert, buttonArgs) =>
                        {
                            if (buttonArgs.ButtonIndex == 1)
                            {
                                UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                            }
                        };
                        alert.Show();
                    }
                };
                btnFavourites.TouchUpInside += (sender, e) =>
                {
                    if (CurrentUser.RetreiveUserId() != 0)
                    {
                        nfloat width = UIScreen.MainScreen.Bounds.Width;
                        width = width / 2 - 15;
                        UICollectionViewFlowLayout flowLayout;
                        flowLayout = new UICollectionViewFlowLayout()
                        {
                            ItemSize        = new CGSize(width, 325.0f),
                            SectionInset    = new UIEdgeInsets(10.0f, 10.0f, 10.0f, 10.0f),
                            ScrollDirection = UICollectionViewScrollDirection.Vertical
                        };
                        NavigationController.PushViewController(new MyFavController(flowLayout), false);
                        NavigationController.NavigationBar.TopItem.Title = "My Favorites";
                        LoggingClass.LogInfo("Entered into Favourite View", screen);
                        BTProgressHUD.Dismiss();
                    }
                    else
                    {
                        BTProgressHUD.Dismiss();
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "This feature is allowed only for VIP Card holders",
                            //Message = "Coming Soon..."
                        };
                        alert.AddButton("OK");
                        alert.AddButton("Know more");
                        alert.Clicked += (senderalert, buttonArgs) =>
                        {
                            if (buttonArgs.ButtonIndex == 1)
                            {
                                UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                            }
                        };
                        alert.Show();
                    }
                };
                btnMyStore.TouchUpInside += (sender, e) =>
                {
                    nfloat width = UIScreen.MainScreen.Bounds.Width;
                    width = width / 2 - 15;
                    UICollectionViewFlowLayout flowLayout;
                    flowLayout = new UICollectionViewFlowLayout()
                    {
                        ItemSize        = new CGSize(width, 325.0f),
                        SectionInset    = new UIEdgeInsets(10.0f, 10.0f, 10.0f, 10.0f),
                        ScrollDirection = UICollectionViewScrollDirection.Vertical
                    };
                    if (CurrentUser.GetStore() == 1)
                    {
                        //BTProgressHUD.Show("Please wait...");
                        NavigationController.Title = "Locations";
                        NavigationController.PushViewController(new PhyCollectionView(flowLayout, 1), false);
                        NavigationController.NavigationBar.TopItem.Title = "My Store  (" + LoggingClass.txtstore1 + ")";
                    }
                    else if (CurrentUser.GetStore() == 2)
                    {
                        //BTProgressHUD.Show("Please wait...");
                        NavigationController.Title = "Locations";
                        NavigationController.PushViewController(new PhyCollectionView(flowLayout, 2), false);
                        NavigationController.NavigationBar.TopItem.Title = "My Store (" + LoggingClass.txtstore2 + ")";
                    }
                    else
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Please choose your preferred store in profile.",
                            //Message = "Coming Soon..."
                        };
                        alert.AddButton("OK");
                        BTProgressHUD.Dismiss();
                        alert.Show();
                    }
                };
                View.AddSubview(btnMyStore);
                View.AddSubview(btnReviews);
                View.AddSubview(btnTastings);
                View.AddSubview(btnFavourites);
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screen, ex.StackTrace);
            }
        }
Пример #3
0
        public async void DownloadAsync()
        {
            NSData HighImgData = null;

            //UIImage HighresImg = null;
            try
            {
                imgprofilepic.Image = new UIImage("Images/loadin.png");
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.StackTrace);
                LoggingClass.LogError(ex.Message, screenid, ex.StackTrace.ToString());
            }
            WebClient webClient = new WebClient();
            //string url = "http://www.my-hd-wallpapers.com/wall/1405244488_moutain-reflect-on-a-lake_800.jpg";
            string url = "https://icsintegration.blob.core.windows.net/profileimages/" + CurrentUser.RetreiveUserId() + ".jpg";

            byte[] imageBytes = null;
            try
            {
                imageBytes = await webClient.DownloadDataTaskAsync(url);

                HighImgData = NSData.FromStream(new MemoryStream(imageBytes));
            }
            catch (TaskCanceledException)
            {
                //this.progressLayout.Visibility = ViewStates.Gone;
                return;
            }
            catch (Exception exe)
            {
                LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
            }

            //HighresImg  =UIImage.LoadFromData(HighImgData);
            try
            {
                if (HighImgData != null)
                {
                    imgprofilepic.Image = UIImage.LoadFromData(HighImgData);
                }
                else
                {
                    imgprofilepic.Image = new UIImage("user1.png");
                }
            }
            catch (Exception Ex)
            {
                LoggingClass.LogError(Ex.Message, screenid, Ex.StackTrace.ToString());
            }
        }
Пример #4
0
        void Internal_ViewDidLoad(bool v)
        {
            try
            {
                //Getting Screen height and width
                nfloat ScreenHeight = UIScreen.MainScreen.Bounds.Height;
                nfloat ScreenWidth  = UIScreen.MainScreen.Bounds.Width;
                //Caliculating height for profile background image
                nfloat probackimgheight = (ScreenHeight - 100) / 3;
                nfloat imgprofile       = 120;
                nfloat Space            = 30;
                nfloat strtx            = 90;
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, KeyBoardDownNotification);
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyBoardUpNotification);

                pickerDataModel = new StatePickerDataModel();
                //pickerDataModel.Items.Add("Select your state");
                pickerDataModel.Items.Add("AL");
                pickerDataModel.Items.Add("AK");
                pickerDataModel.Items.Add("AZ");
                pickerDataModel.Items.Add("AR");
                pickerDataModel.Items.Add("CA");
                pickerDataModel.Items.Add("CO");
                pickerDataModel.Items.Add("CT");
                pickerDataModel.Items.Add("DE");
                pickerDataModel.Items.Add("FL");
                pickerDataModel.Items.Add("GA");
                pickerDataModel.Items.Add("HI");
                pickerDataModel.Items.Add("ID");
                pickerDataModel.Items.Add("IL");
                pickerDataModel.Items.Add("IN");
                pickerDataModel.Items.Add("IA");
                pickerDataModel.Items.Add("KS");
                pickerDataModel.Items.Add("KY");
                pickerDataModel.Items.Add("LA");
                pickerDataModel.Items.Add("ME");
                pickerDataModel.Items.Add("MD");
                pickerDataModel.Items.Add("MA");
                pickerDataModel.Items.Add("MI");
                pickerDataModel.Items.Add("MN");
                pickerDataModel.Items.Add("MS");
                pickerDataModel.Items.Add("MO");
                pickerDataModel.Items.Add("MT");
                pickerDataModel.Items.Add("NE");
                pickerDataModel.Items.Add("NV");
                pickerDataModel.Items.Add("NH");
                pickerDataModel.Items.Add("NJ");
                pickerDataModel.Items.Add("NM");
                pickerDataModel.Items.Add("NY");
                pickerDataModel.Items.Add("NC");
                pickerDataModel.Items.Add("ND");
                pickerDataModel.Items.Add("OH");
                pickerDataModel.Items.Add("OK");
                pickerDataModel.Items.Add("OR");
                pickerDataModel.Items.Add("PA");
                pickerDataModel.Items.Add("RI");
                pickerDataModel.Items.Add("SC");
                pickerDataModel.Items.Add("SD");
                pickerDataModel.Items.Add("TN");
                pickerDataModel.Items.Add("TX");
                pickerDataModel.Items.Add("UT");
                pickerDataModel.Items.Add("VT");
                pickerDataModel.Items.Add("VA");
                pickerDataModel.Items.Add("WA");
                pickerDataModel.Items.Add("WV");
                pickerDataModel.Items.Add("WI");
                pickerDataModel.Items.Add("WY");

                StoreDataModel = new StorePickerDataModel();
                StoreDataModel.Items.Add("Select your store");
                StoreDataModel.Items.Add("Wall");
                StoreDataModel.Items.Add("Pt. Pleasant Beach");
                StoreDataModel.Items.Add("All");

                BTProgressHUD.Dismiss();

                //Background image controller
                UIImageView backgroud = new UIImageView();
                backgroud.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, probackimgheight - 20);
                backgroud.Image = new UIImage("proback.png");
                backgroud.UserInteractionEnabled = false;

                nfloat x = (ScreenWidth / 2) - (imgprofile / 2);
                x = x - 10;
                nfloat y = ((backgroud.Frame.Height) / 2) - 30;

                UIBotton btnImageBack = new UIBotton
                {
                    UserInteractionEnabled = false,
                    Frame           = new CGRect(x, y + 10, imgprofile + 20, imgprofile + 20),
                    BackgroundColor = UIColor.Black
                };
                imgprofilepic = new UIImageView
                {
                    Frame           = new CGRect(x + 10, y + 20, imgprofile, imgprofile),
                    BackgroundColor = UIColor.White
                };
                imgprofilepic.Image = new UIImage("Images/loadin.png");

                btnChange = new UIButton
                {
                    Frame = new CGRect(x + (imgprofilepic.Frame.Width - 10), y + (imgprofilepic.Frame.Height), 30, 30)
                };

                UIImage imgbtnCam = UIImage.FromFile("edit.png");
                imgbtnCam = ResizeImage(imgbtnCam, 25, 25);
                btnChange.SetImage(imgbtnCam, UIControlState.Normal);
                btnChange.SetBackgroundImage(imgbtnCam, UIControlState.Normal);
                //btnChange.BackgroundColor = UIColor.Blue;
                ScreenWidth  = 25;
                ScreenHeight = UIScreen.MainScreen.Bounds.Width - (strtx + 10);
                y            = y + imgprofilepic.Bounds.Height + 50;

                UILabel lblName = new UILabel
                {
                    Text  = "Name:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                txtName = new UITextField
                {
                    Frame       = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    Placeholder = "E.g. John Doe",
                    BorderStyle = UITextBorderStyle.RoundedRect,
                    Font        = UIFont.FromName("HelveticaNeue", 13f)
                                  //UserInteractionEnabled=true
                };
                txtName.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblEmail = new UILabel
                {
                    Text  = "Email:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                //y = y + lblEmail.Bounds.Height;
                txtEmail = new UITextField
                {
                    Placeholder  = "E.g. [email protected]",
                    Frame        = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.EmailAddress,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                                   //UserInteractionEnabled=true
                };
                txtEmail.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblMobile = new UILabel
                {
                    Text  = "Mobile:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };

                txtFirst3 = new UITextField
                {
                    Placeholder = "123",
                    //Text="123",
                    Frame        = new CGRect(strtx, y, 50, ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.NumberPad,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                                   //UserInteractionEnabled = true
                };
                //strtx = strtx + 10;
                UILabel symIphon1 = new UILabel
                {
                    Text  = "-",
                    Frame = new CGRect(strtx + 50, y, 10, ScreenWidth)
                };
                txtSecond3 = new UITextField
                {
                    Placeholder = "456",
                    //Text="123",
                    Frame        = new CGRect(strtx + 60, y, 50, ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.NumberPad,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                };
                UILabel symIphon2 = new UILabel
                {
                    Text  = "-",
                    Frame = new CGRect(strtx + 110, y, 10, ScreenWidth)
                };
                txtLast4 = new UITextField
                {
                    Placeholder = "7890",
                    //Text="1234",
                    Frame        = new CGRect(strtx + 120, y, UIScreen.MainScreen.Bounds.Width - (strtx + 130), ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.NumberPad,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                                   //UserInteractionEnable
                };
                txtLast4.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                txtFirst3.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                txtSecond3.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblAddress = new UILabel
                {
                    Text  = "Address:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                txtAddress = new UITextField
                {
                    Placeholder = "E.g. 1600 Pennsylvania Ave NW",
                    Frame       = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    BorderStyle = UITextBorderStyle.RoundedRect,
                    Font        = UIFont.FromName("HelveticaNeue", 13f)
                };
                txtAddress.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblState = new UILabel
                {
                    Text  = "State:",
                    Frame = new CGRect(10, y + 25, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                stpicker.Frame = new CGRect(strtx, y, 50, 90);
                //stpicker.BackgroundColor = UIColor.LightGray;
                stpicker.Model = pickerDataModel;
                //stpicker.Hidden = true;

                //
                nfloat  zipx       = strtx + 80;
                UILabel lblZipcode = new UILabel
                {
                    Text  = "Zipcode:",
                    Frame = new CGRect(zipx, y + 25, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                txtZipcode = new UITextField
                {
                    Placeholder            = "E.g. 08632",
                    Frame                  = new CGRect(zipx + 70, y + 25, 80, ScreenWidth),
                    BorderStyle            = UITextBorderStyle.RoundedRect,
                    UserInteractionEnabled = true,
                    KeyboardType           = UIKeyboardType.NumberPad,
                    Font = UIFont.FromName("HelveticaNeue", 13f)
                };
                txtZipcode.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + 90;
                //y = y + Space;
                UILabel lblCardExpiry = new UILabel
                {
                    Text  = "Expiry:",
                    Frame = new CGRect(UIScreen.MainScreen.Bounds.Width / 2, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                UILabel lblCardDate = new UILabel
                {
                    Frame = new CGRect((UIScreen.MainScreen.Bounds.Width / 2) + 70, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue", 13f)
                };
                //y = y + Space;
                UILabel lblcardnumber = new UILabel
                {
                    Text  = "Card #:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                UILabel CardNumer = new UILabel
                {
                    Frame = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue", 13f)
                };
                y = y + Space;
                UILabel lblMystore = new UILabel
                {
                    Text  = "My Store:",
                    Frame = new CGRect(10, y + 25, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                StorePicker.Frame = new CGRect(strtx, y, UIScreen.MainScreen.Bounds.Width - (strtx + 10), 90);
                //StorePicker.BackgroundColor = UIColor.LightGray;
                StorePicker.Hidden = false;
                y         = y + 90;
                btnUpdate = new UIButton();
                btnUpdate.SetTitle("Update", UIControlState.Normal);
                btnUpdate.Frame = new CGRect(UIScreen.MainScreen.Bounds.Width / 2 - 25, y, 100, 30);
                btnUpdate.SetTitleColor(UIColor.White, UIControlState.Normal);
                btnUpdate.BackgroundColor     = UIColor.Purple;
                btnUpdate.Font                = UIFont.FromName("HelveticaNeue-Bold", 16f);
                btnUpdate.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
                StorePicker.Model             = StoreDataModel;
                Scroll = new UIScrollView
                {
                    Frame            = new CGRect(0, 0, View.Frame.Width, View.Frame.Height),
                    ContentSize      = new CGSize(View.Frame.Width, View.Frame.Height),
                    BackgroundColor  = UIColor.White,
                    AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
                };
                UITapGestureRecognizer taps = new UITapGestureRecognizer();
                taps.CancelsTouchesInView = false;
                taps.AddTarget(() => Scroll.EndEditing(true));

                if (CurrentUser.RetreiveUserId() == 0)
                {
                    Scroll.AddSubview(stpicker);
                    Scroll.AddSubview(StorePicker);
                    StorePicker.UserInteractionEnabled = false;
                    stpicker.UserInteractionEnabled    = false;
                    txtName.UserInteractionEnabled     = false;
                    txtEmail.UserInteractionEnabled    = false;
                    txtFirst3.UserInteractionEnabled   = false;
                    txtSecond3.UserInteractionEnabled  = false;
                    txtLast4.UserInteractionEnabled    = false;
                    txtAddress.UserInteractionEnabled  = false;
                    txtZipcode.UserInteractionEnabled  = false;
                    btnChange.UserInteractionEnabled   = false;
                    btnUpdate.UserInteractionEnabled   = false;
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "This feature is allowed only for VIP Card holders",
                        //Message = "Coming Soon..."
                    };

                    alert.AddButton("OK");
                    alert.AddButton("Log in");
                    alert.AddButton("Know more");
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 1)
                        {
                            CurrentUser.Clear();
                            LoginViewController yourController = new LoginViewController();
                            yourController.nav      = NavCtrl;
                            yourController.RootTabs = CurrentUser.RootTabs;
                            NavCtrl.PushViewController(yourController, false);
                        }
                    };
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 2)
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                        }
                    };
                    alert.Show();
                }
                else
                {
                    Scroll.AddSubview(stpicker);
                    Scroll.AddSubview(StorePicker);
                    DownloadAsync();
                    cRes = svc.GetCustomerDetails(CurrentUser.RetreiveUserId()).Result;
                    if (cRes.customer.CardNumber != null && cRes.customer.CardNumber != "")
                    {
                        name          = cRes.customer.FirstName + " " + cRes.customer.LastName;
                        name          = name.Trim();
                        txtName.Text  = name;
                        txtEmail.Text = cRes.customer.Email;
                        if (cRes.customer.PhoneNumber != null && cRes.customer.PhoneNumber != "")
                        {
                            //if (cRes.customer.PhoneNumber.Length != 10)
                            //{
                            //Console.WriteLine(cRes.customer.PhoneNumber);
                            txtFirst3.Text = cRes.customer.PhoneNumber.Substring(0, 3);
                            //Console.WriteLine(cRes.customer.PhoneNumber.Substring(0, 3));
                            txtSecond3.Text = cRes.customer.PhoneNumber.Substring(3, 3);
                            //Console.WriteLine(cRes.customer.PhoneNumber.Substring(3, 3));
                            txtLast4.Text = cRes.customer.PhoneNumber.Substring(6);
                            //Console.WriteLine(cRes.customer.PhoneNumber.Substring(6));
                            //}
                        }
                        CardNumer.Text   = cRes.customer.CardNumber;
                        lblCardDate.Text = cRes.customer.ExpireDate.ToString("MM-dd-yyyy");
                        txtZipcode.Text  = cRes.customer.Zip;
                        string state = cRes.customer.State;
                        if (pickerDataModel.Items.Contains(state))
                        {
                            int i = pickerDataModel.Items.FindIndex(n => n == state);
                            stpicker.Select(i, 0, false);
                        }
                        int prefStore = cRes.customer.PreferredStore;
                        StorePicker.Select(prefStore, 0, false);
                        txtAddress.Text = cRes.customer.Address1 + cRes.customer.Address2 + cRes.customer.City;
                        txtZipcode.AccessibilityScroll(UIAccessibilityScrollDirection.Up);
                        btnChange.TouchUpInside += (sender, e) =>
                        {
                            try
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "Please choose an option to upload profile picture",
                                    //Message = "Coming Soon..."
                                };
                                alert.AddButton("Cancel");
                                alert.AddButton("Camera");
                                alert.AddButton("Gallery");
                                alert.Clicked += (senderalert, buttonArgs) =>
                                {
                                    if (buttonArgs.ButtonIndex == 1)
                                    {
                                        try
                                        {
                                            IsCameraAuthorized();
                                            TweetStation.Camera.TakePicture(this, (obj) =>
                                            {
                                                var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
                                                var meta  = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary;
                                                UploadProfilePic(photo);
                                            });
                                        }
                                        catch (Exception exe)
                                        {
                                            LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                                        }
                                    }
                                };
                                alert.Clicked += (senderalert, buttonArgs) =>
                                {
                                    if (buttonArgs.ButtonIndex == 2)
                                    {
                                        imagePicker                       = new UIImagePickerController();
                                        imagePicker.SourceType            = UIImagePickerControllerSourceType.PhotoLibrary;
                                        imagePicker.MediaTypes            = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
                                        imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                                        imagePicker.Canceled             += Handle_Canceled;
                                        NavCtrl.PresentModalViewController(imagePicker, true);
                                    }
                                };
                                alert.Show();
                            }
                            catch (Exception exe)
                            {
                                LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                            }
                        };

                        btnUpdate.TouchUpInside += async delegate
                        {
                            string txtMobilenumber = txtFirst3.Text + txtSecond3.Text + txtLast4.Text;
                            if (txtMobilenumber.Length != 10)
                            {
                                BTProgressHUD.ShowErrorWithStatus("Phone number is invalid", 3000);
                            }
                            if ((txtEmail.Text.Contains("@")) == false || (txtEmail.Text.Contains(".")) == false)
                            {
                                BTProgressHUD.ShowErrorWithStatus("Email is invalid", 3000);
                            }
                            else if ((txtZipcode.Text.Length != 5))
                            {
                                BTProgressHUD.ShowErrorWithStatus("Zipcode is invalid", 3000);
                            }
                            else if (txtFirst3.Text.Length != 3 || txtSecond3.Text.Length != 3 || txtLast4.Text.Length != 4)
                            {
                                BTProgressHUD.ShowErrorWithStatus("Phone number is invalid", 3000);
                            }
                            else
                            {
                                BTProgressHUD.Show("Updating Profile...");
                                LoggingClass.LogInfo("Update button into Profile View", screenid);
                                Customer cust = new Customer();
                                cust.CustomerID = CurrentUser.RetreiveUserId();
                                cust.Address1   = txtAddress.Text;
                                name            = txtName.Text;
                                name            = name.Trim();
                                try
                                {
                                    string[] str1 = name.Split(' ');
                                    if (str1.Length == 2)
                                    {
                                        cust.FirstName = str1[0];
                                        cust.LastName  = str1[1];
                                    }
                                    else
                                    {
                                        cust.FirstName = str1[0] + str1[1];
                                        cust.LastName  = str1[2];
                                    }
                                }
                                catch (Exception exe)
                                {
                                    LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                                }
                                cust.Email       = txtEmail.Text;
                                cust.PhoneNumber = txtMobilenumber;

                                if (pickerDataModel.SelectedItem == "AL")
                                {
                                    if (pickerDataModel.Items.Contains(cRes.customer.State))
                                    {
                                        int i = pickerDataModel.Items.FindIndex(n => n == cRes.customer.State);
                                        stpicker.Select(i, 0, false);
                                    }
                                    cust.State = cRes.customer.State;
                                }
                                else
                                {
                                    cust.State = pickerDataModel.SelectedItem;
                                }
                                cust.Zip = txtZipcode.Text;
                                if (StoreDataModel.SelectedItem == 0)
                                {
                                    cust.PreferredStore = cRes.customer.PreferredStore;
                                    StorePicker.Select(cRes.customer.PreferredStore, 0, false);
                                    CurrentUser.PutStore(cust.PreferredStore);
                                }
                                else
                                {
                                    cust.PreferredStore = StoreDataModel.SelectedItem;
                                    CurrentUser.PutStore(cust.PreferredStore);
                                }
                                await svc.UpdateCustomer(cust);

                                BTProgressHUD.ShowSuccessWithStatus("Profile Updated.");
                            }
                        };
                    }
                    else
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title   = "Sorry",
                            Message = "Something went wrong. We are on it"
                        };

                        alert.AddButton("OK");
                        alert.Show();
                    }
                }

                Scroll.AddGestureRecognizer(taps);
                Scroll.AddSubview(backgroud);
                Scroll.AddSubview(btnImageBack);
                Scroll.AddSubview(imgprofilepic);
                Scroll.AddSubview(btnChange);
                Scroll.AddSubview(lblName);
                Scroll.AddSubview(txtName);
                Scroll.AddSubview(lblEmail);
                Scroll.AddSubview(txtEmail);
                Scroll.AddSubview(lblMobile);
                Scroll.AddSubview(txtFirst3);
                Scroll.AddSubview(symIphon1);
                Scroll.AddSubview(txtSecond3);
                Scroll.AddSubview(symIphon2);
                Scroll.AddSubview(txtLast4);
                Scroll.AddSubview(lblState);
                //Scroll.AddSubview(stpicker);
                Scroll.AddSubview(lblAddress);
                Scroll.AddSubview(txtAddress);
                Scroll.AddSubview(lblZipcode);
                Scroll.AddSubview(txtZipcode);
                //Scroll.AddSubview(StorePicker);
                Scroll.AddSubview(lblMystore);
                Scroll.AddSubview(lblCardExpiry);
                Scroll.AddSubview(lblCardDate);
                Scroll.AddSubview(lblcardnumber);
                Scroll.AddSubview(CardNumer);
                Scroll.AddSubview(btnUpdate);

                //for (int i = 0; i<Scroll.Subviews.Length ; i++)
                //{
                //	nfloat n = Scroll.Subviews[i].Bounds.Height;// Frame.Size.Height;
                //	h = h + n;
                //}
                //Console.WriteLine(h+"\n"+ScreenHeight);
                h = y + 50;
                Scroll.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, h);
                View = (Scroll);
            }
            catch (Exception e)
            {
                UIAlertView alert = new UIAlertView()
                {
                    Title   = "Sorry",
                    Message = "Something went wrong. We are on it"
                };

                alert.AddButton("OK");
                alert.Show();
                LoggingClass.LogError(e.Message, screenid, e.StackTrace);
                //Console.WriteLine(e.Message + "\n" + e.StackTrace);
            }
        }
		public override void ViewDidLoad()
		{
			try
			{
				nfloat starty = 70;
				nfloat width = UIScreen.MainScreen.Bounds.Width;
				width = width / 2 - 15;
				if (Reachability.IsHostReachable("https://www.google.com") == false)
				{
					UIAlertView alert = new UIAlertView()
					{
						Title = "Sorry",
						Message = "Not connected to internet,Connect and re try it."
					};

					alert.AddButton("OK");
					alert.Show();
				}
				if (CurrentUser.GetCardNumber() != null)
				{
					PreInfo(CurrentUser.GetCardNumber());
				}
				CGSize sTemp = new CGSize(View.Frame.Width-10, 100);


				MobileBarcodeScanner scanner = new MobileBarcodeScanner();
				nfloat h = 31.0f;
				nfloat w = View.Bounds.Width;
				nfloat imageheight = screenheight/5;
				nfloat imagewidth = UIScreen.MainScreen.Bounds.Width;
				var imgLogo = new UIImageView();
				imgLogo.Frame = new CGRect(((imagewidth/2)-(imageheight/2)), starty, imageheight, imageheight);
				imgLogo.Image = UIImage.FromFile("logo5.png");
				y = starty + imageheight;
				lblIns = new UILabel();
				lblIns.Text = "Please scan your VIP card barcode by touching below card:";
				lblIns.LineBreakMode = UILineBreakMode.WordWrap;
				lblIns.Lines = 0;
				sTemp = lblIns.SizeThatFits(sTemp);
				lblIns.Frame = new CGRect(0, y, View.Frame.Width-10, sTemp.Height);
				lblIns.TextAlignment = UITextAlignment.Center;
				lblIns.TextColor = UIColor.Black;
				//Console.WriteLine(y+"\n"+sTemp.Height);

				y = y+sTemp.Height;
				lblInfo = new UILabel();
				lblInfo.Frame = new CGRect(20, y, View.Frame.Width-10, h);
				lblInfo.LineBreakMode = UILineBreakMode.WordWrap;
				lblInfo.Lines = 0;
				lblInfo.TextAlignment = UITextAlignment.Center;
				lblInfo.TextColor = UIColor.Black;

				lblContactus = new UILabel();
				lblContactus.TextColor = UIColor.Red;
				lblContactus.TextAlignment = UITextAlignment.Center;
				lblContactus.Hidden = true;

				nfloat hei = 180 + lblIns.Frame.Height + 10;
				btnCardScanner= new UIButton();
				if (screenheight <= 568)
				{
					btnCardScanner.Frame = new CGRect((View.Frame.Width / 2) - 100, y, 200, 122);
				}
				else
				{
					btnCardScanner.Frame = new CGRect((View.Frame.Width / 2) - 100, y, 200, 152);
				}
				btnCardScanner.SetBackgroundImage(new UIImage("card-icon.png"), UIControlState.Normal);

				//height setting for button
				start = hei + btnCardScanner.Frame.Height + 10;
				//Console.WriteLine(hei);
				//Console.WriteLine(btnCardScanner.Frame.Height);
				//Console.WriteLine(start);
				//Console.WriteLine(View.Frame.Height);
				//568
				//Scanning Button Click event
				btnCardScanner.TouchUpInside += async (sender, e) =>
				{
					
					try
					{
						scanner.UseCustomOverlay = false;
						var result = await scanner.Scan();

						if (result != null)
						{
							LoggingClass.LogInfo("User tried to login with" + result.Text, screenid);
							PreInfo(result.Text);
						}
					}
					catch (Exception exe)
					{
						LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
					}
				};
				y = y + 200;
				//nfloat strtguest = strtbtn + btnLogin.Frame.Height + 10;
				UILabel lblGuest = new UILabel();
				lblGuest.Frame = new CGRect(20, View.Frame.Height - 50, View.Frame.Width, h);
				lblGuest.Text = "Not a VIP Member?";
				lblGuest.TextAlignment = UITextAlignment.Left;
				lblGuest.Font = UIFont.ItalicSystemFontOfSize(17);
				lblGuest.TextColor = UIColor.Black;

				btnGuestLogin = new UIButton(new CGRect(180, View.Frame.Height - 50, 120, 30));
				btnGuestLogin.SetTitle("Guest Log In", UIControlState.Normal);
				btnGuestLogin.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				btnGuestLogin.SetTitleColor(UIColor.White, UIControlState.Normal);
				btnGuestLogin.BackgroundColor = UIColor.Purple;
				//btnGuestLogin.SetImage(UIImage.FromFile ("Images/gl.png"), UIControlState.Normal);

				btnLogin = new UIButton(new CGRect(180, strtbtn, 120, 30));
				btnLogin.SetTitle("Log In", UIControlState.Normal);
				btnLogin.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				btnLogin.SetTitleColor(UIColor.White, UIControlState.Normal);
				btnLogin.BackgroundColor = UIColor.Purple;

				btnResend = new UIButton(new CGRect(30, strtbtn, 120, 30));
				btnResend.SetTitle("Resend Email", UIControlState.Normal);
				btnResend.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				btnResend.SetTitleColor(UIColor.White, UIControlState.Normal);
				btnResend.BackgroundColor = UIColor.Purple;

				BtnTest1 = new UIButton(new CGRect(200, strtbtn, 100, 30));
				BtnTest1.SetTitle("Continue", UIControlState.Normal);
				BtnTest1.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				BtnTest1.SetTitleColor(UIColor.White, UIControlState.Normal);
				BtnTest1.BackgroundColor = UIColor.Purple;

				BtnTest2 = new UIButton(new CGRect(30, strtbtn, 140, 30));
				BtnTest2.SetTitle("Update E-Mail Id", UIControlState.Normal);
				BtnTest2.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				BtnTest2.SetTitleColor(UIColor.White, UIControlState.Normal);
				BtnTest2.BackgroundColor = UIColor.Purple;

				btnVerify = new UIButton(new CGRect(24, imageheight + 270, 240, 20));
				btnVerify.SetTitle("Verify", UIControlState.Normal);
				btnVerify.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
				btnVerify.SetTitleColor(UIColor.Purple, UIControlState.Normal);
				btnGuestLogin.TouchDown += async (sender, e) =>
				   {
					   CurrentUser.Store("0", "Guest");
					   if (RootTabs == null || _window == null)
					   {
						   _window = CurrentUser.window;
						   RootTabs = CurrentUser.RootTabs;
						   nav = new UINavigationController(RootTabs);
						   //AddNavigationButtons(nav);
						   _window.RootViewController = nav;
						   //nav.DismissViewController(true);
					   }
					   nav = new UINavigationController(RootTabs);
					   AddNavigationButtons(nav);
					   CurrentUser.RootTabs = RootTabs;
					   _window.RootViewController = nav;
					   CurrentUser.window = _window;
					   await svc.InsertUpdateGuest("Didn't get the token");

					   //this.NavigationController.PopToRootViewController (true);

				   };
				View.AddSubview(BtnTest1);
				View.AddSubview(BtnTest2);
				View.AddSubview(btnResend);
				View.AddSubview(btnLogin);
				View.AddSubview(imgLogo);
				View.AddSubview(btnGuestLogin);
				View.AddSubview(lblIns);
				View.AddSubview(btnCardScanner);
				View.AddSubview(lblInfo);
				View.AddSubview(lblGuest);
				View.AddSubview(lblContactus);
				View.BackgroundColor = UIColor.White;

			}
			catch (Exception exe)
			{
				LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
			}

		}
		public async void ShowInfo(CustomerResponse cr, Boolean Continue)
		{
			BTProgressHUD.Show("Please wait...");
			CGSize sTemp = new CGSize(View.Frame.Width, 100);
			try
			{
				if (CardNumber != null)
				{
					CurrentUser.PutCardNumber(CardNumber);
				}
				if (cr != null)
				{

					if (cr.customer.Email != "" && cr.customer.Email != null)
					{
						if ((cr.ErrorDescription == null && cr.ErrorDescription == "") || cr.customer.CustomerID != 0)
						{
							lblInfo.Text = "Hi " + cr.customer.FirstName + " " +
								cr.customer.LastName + ",\nWe have sent you a verification link to "
								+ cr.customer.Email + ". Please click on the activation link to activate the account.";
						}
						else
						{
							lblInfo.Text = cr.ErrorDescription;
						}
						lblInfo.LineBreakMode = UILineBreakMode.WordWrap;
						lblInfo.Lines = 0;
						sTemp = lblInfo.SizeThatFits(sTemp);
						//Console.WriteLine("Show info "+y);
						lblInfo.Frame = new CGRect(10, y, View.Frame.Width - 10, sTemp.Height);
						lblInfo.TextAlignment = UITextAlignment.Left;
						lblInfo.TextColor = UIColor.Black;
						CurrentUser.StoreId(cr.customer.CustomerID.ToString());
						try
						{
							BtnTest1.Hidden = true;
							BtnTest2.Hidden = true;
							btnLogin.Hidden = false;
							btnResend.Hidden = false;
						}
						catch (Exception exe)
						{
							//Console.WriteLine(exe.Message);
						}

						start = 0;
						start = y + lblInfo.Frame.Height + 10;
						btnLogin.Frame = new CGRect(180, start, 120, 30);
						btnResend.Frame = new CGRect(30, start, 120, 30);

						btnResend.TouchUpInside += async (send, eve) =>
						{
							BTProgressHUD.Show("Sending verification email to " + cr.customer.Email);
							if (CardNumber != null)
							{
								await svc.ResendEMail(CardNumber);
							}
							else
							{
								await svc.ResendEMail(CurrentUser.GetCardNumber());
							}
							BTProgressHUD.ShowSuccessWithStatus("Sent");
						};
						btnLogin.TouchUpInside += (sen, ev) =>
						{
							try
							{
								BTProgressHUD.Show("Checking email verification");
								EmailVerification();
							}
							catch (Exception ex)
							{
								LoggingClass.LogError(ex.Message, screenid, ex.StackTrace.ToString());
							}

						};
						BTProgressHUD.Dismiss();
					}
					else
					{
						lblInfo.Text = cr.ErrorDescription;
						//lblInfo.TextAlignment = UITextAlignment.Center;
						lblInfo.TextColor = UIColor.Red;
						try
						{
							btnLogin.Hidden = true;
							btnResend.Hidden = true;
						}
						catch (Exception exe)
						{
							LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
						}
						sTemp = lblInfo.SizeThatFits(sTemp);
						lblInfo.Frame = new CGRect(0, start, View.Frame.Width - 10, sTemp.Height);
						BTProgressHUD.Dismiss();
					}
				}
				else
				{

					lblInfo.Text = "Sorry. Your Card number is not matching our records.\n Please re-scan Or Try app as Guest Log In.";
					lblInfo.TextColor = UIColor.Red;
					lblInfo.TextAlignment = UITextAlignment.Center;
					sTemp = lblInfo.SizeThatFits(sTemp);
					lblInfo.Frame = new CGRect(0, start, View.Frame.Width - 10, sTemp.Height);
					try
					{
						if (btnLogin != null || btnResend != null)
						{
							btnLogin.SetTitleColor(UIColor.White, UIControlState.Normal);
							btnResend.SetTitleColor(UIColor.White, UIControlState.Normal);
							btnLogin.BackgroundColor = UIColor.White;
							btnResend.BackgroundColor = UIColor.White;
						}
					}
					catch (Exception ex)
					{
						LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
					}
					BTProgressHUD.Dismiss();
				}
				BTProgressHUD.Dismiss();
			}
			catch (Exception exe)
			{
				lblInfo.Text = "Something went wrong.We're on it.";
				lblInfo.TextColor = UIColor.Red;
				sTemp = lblInfo.SizeThatFits(sTemp);
				lblInfo.Frame = new CGRect(0, start, View.Frame.Width - 10, sTemp.Height);
				LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
			}
			BTProgressHUD.Dismiss();
		}
		public async void PreInfo(string CardNumber)
		{
			CGSize sTemp = new CGSize(View.Frame.Width, 100);
			try
			{
				if (btnLogin != null && btnResend != null)
				{
					btnLogin.Hidden = true;
					btnResend.Hidden = true;
				}
				BTProgressHUD.Show(LoggingClass.txtpleasewait);
				cr = await svc.AuthencateUser("email", CardNumber, uid_device);
				if (CardNumber != null)
				{
					CurrentUser.PutCardNumber(CardNumber);
				}
				if (cr != null)
				{
					//Updating device token in different thread
					var TaskA = new System.Threading.Tasks.Task(() =>
					{
						updatetoken(cr);
					});
					TaskA.Start();
					//Storing customerid and updating the device tokens
					CurrentUser.StoreId(cr.customer.CustomerID.ToString());
					if (cr.customer.Email != null && cr.customer.Email != "")
					{
						if ((cr.ErrorDescription == null && cr.ErrorDescription == "") && cr.customer.CustomerID != 0)
						{
							//Console.WriteLine("Error Description is not there");
							lblInfo.Text = "Hi " + cr.customer.FirstName
								+ " " + cr.customer.LastName +
								", \nWe are sending a verification email to " +
								cr.customer.Email +
								" . To proceed press continue.\nTo change your emailAddress click on Update.";
						}
						else
						{
							lblInfo.Text = cr.ErrorDescription;
						}
						lblInfo.LineBreakMode = UILineBreakMode.WordWrap;
						lblInfo.TextAlignment = UITextAlignment.Justified;
						lblInfo.Lines = 0;
						sTemp = lblInfo.SizeThatFits(sTemp);
						if (screenheight <= 568)
						{
							y = y - 80;
							lblInfo.Frame = new CGRect(10, y, View.Frame.Width - 10, sTemp.Height);
						}
						else
						{
							lblInfo.Frame = new CGRect(10, y, View.Frame.Width - 10, sTemp.Height);
						}
						lblInfo.TextAlignment = UITextAlignment.Left;
						lblInfo.TextColor = UIColor.Black;
						lblInfo.Font = UIFont.FromName("HelveticaNeue", 15f);
						CurrentUser.StoreId(cr.customer.CustomerID.ToString());
						start = 0;
						start = y + lblInfo.Frame.Height + 10;
						//Console.WriteLine("Error " + cr.ErrorDescription);
						BtnTest1.Frame = new CGRect(180, start, 120, 30);
						BtnTest2.Frame = new CGRect(30, start, 140, 30);
						try
						{
							BtnTest1.Hidden = false;
							BtnTest2.Hidden = false;
						}
						catch (Exception ex)
						{
							LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
						}
						BtnTest1.TouchUpInside += async delegate
						 {
							 BTProgressHUD.Show(LoggingClass.txtloading);
							 cr = await svc.ContinueService(cr);
							 ShowInfo(cr, false);
						 };
						BtnTest2.TouchUpInside += delegate
						{
							BTProgressHUD.Show(LoggingClass.txtloading);
							UpdateEmail("Please enter your new E-mail Id");
						};
					}
					else
					{
						emailnotpresent = true;
						//Console.WriteLine("Error Discription before if " + cr.ErrorDescription);
						if ((cr.ErrorDescription == null && cr.ErrorDescription == "") || cr.customer.CustomerID != 0)
						{
							//Console.WriteLine("Error Discription in if " + cr.ErrorDescription);
							UpdateEmail("Hi " + cr.customer.FirstName + cr.customer.LastName +
										", \nIt seems we do not have your email address! Please update it so we can send you a verification link that will activate your account.");
						}
						else
						{
							UpdateEmail(cr.ErrorDescription);
						}
					}
					BTProgressHUD.Dismiss();

				}
				else
				{
					try
					{
						BtnTest2.Hidden = true;
						BtnTest1.Hidden = true;
						btnLogin.Hidden = true;
						btnResend.Hidden = true;
					}
					catch (Exception ex)
					{
						//Console.WriteLine(ex.Message);
					}
					lblInfo.Text = "Sorry. Your Card number is not matching our records.\n Please re-scan Or Try app as Guest Log In.";
					lblInfo.TextColor = UIColor.Red;
					lblInfo.TextAlignment = UITextAlignment.Center;
					sTemp = lblInfo.SizeThatFits(sTemp);
					lblInfo.Frame = new CGRect(0, y, View.Frame.Width - 10, sTemp.Height);
					BTProgressHUD.Dismiss();
				}
			}
			catch (Exception ex)
			{
				//Console.WriteLine(ex.Message);
			}
		}