public override void ViewDidLoad()
 {
     try
     {
         LoggingClass.LogInfo("Entered into MyReviews View", screenid);
         int userId = Convert.ToInt32(CurrentUser.RetreiveUserId());
         var myData = sw.GetItemReviewUID(userId).Result;
         var data   = sw.GetMyTastingsList(userId).Result;
         Noreviews = new UILabel();
         if (data.TastingList.Count != 0)
         {
             Noreviews.Text = "You have tasted " + data.TastingList.Count + " wines.\n We would love to hear your feedback.";
         }
         else
         {
             Noreviews.Text = "Please taste and then review.";
         }
         Noreviews.TextAlignment = UITextAlignment.Center;
         Noreviews.LineBreakMode = UILineBreakMode.WordWrap;
         Noreviews.Lines         = 0;
         Noreviews.TextColor     = UIColor.Black;
         CGSize sTemp = new CGSize(View.Frame.Width, 100);
         sTemp           = Noreviews.SizeThatFits(sTemp);
         Noreviews.Frame = new CGRect(0, 50, View.Frame.Width, sTemp.Height);
         ImgIns          = new UIImageView();
         ImgIns.Image    = UIImage.FromFile("ReviewIns.png");
         ImgIns.Frame    = new CGRect((View.Frame.Width / 2) - 150, 120, 300, 300);
         if (myData.Reviews.Count == 0)
         {
             TableView.SeparatorColor = UIColor.Clear;
             View.AddSubview(Noreviews);
             View.AddSubview(ImgIns);
         }
         else
         {
             TableView.AllowsSelection = false;
             TableView.Source          = new MyReviewTableSource(myData.Reviews.ToList(), NavigationController, this);
         }
     }
     catch (Exception ex)
     {
         UIAlertView alert = new UIAlertView()
         {
             Title = "Something went wrong,we're on it.",
         };
         alert.AddButton("Ok");
         LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
     }
 }
Пример #2
0
        public override void ViewDidLoad()
        {
            try
            {
                int userId = Convert.ToInt32(CurrentUser.RetreiveUserId());

                if (userId == 0)
                {
                    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();
                }
                else
                {
                    var tastingData = sw.GetMyTastingsList(userId).Result;
                    if (tastingData.TastingList.Count == 0)
                    {
                        UILabel lblNoTastings = new UILabel();
                        lblNoTastings.Text          = tastingData.ErrorDescription;
                        lblNoTastings.TextAlignment = UITextAlignment.Center;
                        lblNoTastings.LineBreakMode = UILineBreakMode.WordWrap;
                        lblNoTastings.Lines         = 0;
                        CGSize sTemp = new CGSize(View.Frame.Width, 100);
                        sTemp = lblNoTastings.SizeThatFits(sTemp);
                        lblNoTastings.Frame      = new CGRect(0, 50, View.Bounds.Width, sTemp.Height);
                        TableView.SeparatorColor = UIColor.Clear;
                        View.AddSubview(lblNoTastings);
                        UIButton btnrefresh = new UIButton();
                        btnrefresh.Frame = new CGRect(0, 90, 50, 50);
                        btnrefresh.SetTitle("Swipe down to refresh", UIControlState.Normal);
                        btnrefresh.TouchUpInside += delegate {
                            RefreshParent();
                        };
                        View.AddSubview(btnrefresh);
                    }
                    //UIAlertView alert = new UIAlertView()
                    //{
                    //	Title = "Please swipe down to get your new tastings.",
                    //	//Message = "Coming Soon..."
                    //};
                    //alert.AddButton("OK");
                    //alert.Show();
                    this.View.Add(refreshControl);
                    refreshControl.ValueChanged += delegate {
                        RefreshParent();
                    };
                    TableView.AllowsSelection = false;
                    TableView.Source          = new MyTastingTableSource(tastingData.TastingList.ToList(), NavigationController, this);
                    //BTProgressHUD.Dismiss();
                }
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.Message, screen, ex.StackTrace);
                Console.WriteLine(ex.Message);
            }
        }