public override void ViewDidLoad()
        {
            try
            {
                base.ViewDidLoad();
                this.Title = "Forum Posts";

                View.Frame = UIScreen.MainScreen.Bounds;
                View.BackgroundColor = UIColor.White;
                View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                table = new UITableView(new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height));

                Action<ForumModel> skaters = new Action<ForumModel>(UpdateAdapter);
                Forum.PullForumTopics(SettingsMobile.Instance.User.MemberId.ToString(), SettingsMobile.Instance.User.LoginId.ToString(), "league", 0, 0, 0, 30, skaters);
                // Perform any additional setup after loading the view
                loading = new LoadingView();
                loading.ShowActivity("loading posts");

                var group = initialModel.Groups.Where(x => x.GroupId == 0).FirstOrDefault();
                if (group != null)
                    initialArray.AddRange(group.Topics);
                source = new ForumTableView(initialArray, initialModel.ForumId, this.NavigationController);
                table.Source = source;
                table.RowHeight = 50;

                this.NavigationItem.BackBarButtonItem = new UIBarButtonItem();
                this.NavigationItem.BackBarButtonItem.Title = "Topics";

                //View.Add(table);

                navigation = new FlyoutNavigationController(UITableViewStyle.Plain);
                navigation.View.Frame = new RectangleF(0, 60, View.Bounds.Width, View.Bounds.Height);
                navigation.ViewControllers = new[] {
            new UIViewController { View = table },
        };
                View.AddSubview(navigation.View);


                var button1 = new UIBarButtonItem("Gs", UIBarButtonItemStyle.Plain, (sender, args) =>
                {
                    navigation.ToggleMenu();

                });
                var button2 = new UIBarButtonItem(UIBarButtonSystemItem.Add, (sender, args) =>
                {
                    AddForumTopicViewController add = new AddForumTopicViewController(initialModel.GroupId, initialModel.ForumId, currentGroupName);
                    this.NavigationController.PushViewController(add, true);

                });
                this.NavigationItem.SetRightBarButtonItems(new UIBarButtonItem[] { button1, button2 }, false);

                Action selected = new Action(SelectedNavigationItem);
                navigation.SelectedIndexChanged = selected;

            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
            }
        }
        public override void ViewDidLoad()
        {
            try
            {
                base.ViewDidLoad();
                this.Title = "Derby Games";

                View.Frame = UIScreen.MainScreen.Bounds;
                View.BackgroundColor = UIColor.White;
                View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                table = new UITableView(new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height));

                Action<GamesJson> skaters = new Action<GamesJson>(UpdateAdapter);
                Game.PullCurrentGames(skaters);
                Action<GamesJson> skaters1 = new Action<GamesJson>(UpdateAdapter);
                Game.PullPastGames(PAGE_COUNT, lastPagePulled, skaters1);
                // Perform any additional setup after loading the view
                loading = new LoadingView();
                loading.ShowActivity("loading games");
                source = new GamesTableView(initialArray.Games, this.NavigationController, View);
                source.GotCell += source_GotCell;
                table.Source = source;
                table.RowHeight = 160;

                this.NavigationItem.BackBarButtonItem = new UIBarButtonItem();
                this.NavigationItem.BackBarButtonItem.Title = "Games";

                View.Add(table);
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
            }
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (ReloadData)
            {
                Action<ForumTopicModel> skaters = new Action<ForumTopicModel>(UpdateAdapter);
                Forum.PullForumTopic(SettingsMobile.Instance.User.MemberId.ToString(), SettingsMobile.Instance.User.LoginId.ToString(), initialModel.TopicId, skaters);
                loading = new LoadingView();
                loading.ShowActivity("loading topic");

            }
        }
        public override void ViewDidLoad()
        {
            try
            {
                //View = new UniversalView();

                base.ViewDidLoad();
                this.Title = "Derby Events";

                View.Frame = UIScreen.MainScreen.Bounds;
                View.BackgroundColor = UIColor.White;
                View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                table = new UITableView(new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height));

                Action<EventsJson> skaters = new Action<EventsJson>(UpdateAdapter);
                Calendar.PullEvents(lastPagePulled, PAGE_COUNT, skaters);
                // Perform any additional setup after loading the view
                loading = new LoadingView();
                loading.ShowActivity("loading events");
                source = new EventsTableView(initialArray.Events, this.NavigationController);
                source.GotCell += source_GotCell;
                table.Source = source;
                table.RowHeight = 80;


                searchBar = new UISearchBar(new RectangleF(0, 0, 200, 44));
                searchBar.SetShowsCancelButton(true, false);
                searchBar.CancelButtonClicked += searchBar_CancelButtonClicked;
                searchBar.SearchButtonClicked += searchBar_SearchButtonClicked;


                this.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(UIBarButtonSystemItem.Search, (sender, args) =>
    {
        searchBar.BecomeFirstResponder();
        UIView searchBarView = new UIView(new RectangleF(0, 0, 250, 44));
        searchBarView.AddSubview(searchBar);
        this.NavigationItem.TitleView = searchBarView;
    })
, true);

                this.NavigationItem.BackBarButtonItem = new UIBarButtonItem();
                this.NavigationItem.BackBarButtonItem.Title = "Events";

                View.Add(table);
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
            }

        }
        public override void ViewDidLoad()
        {
            try
            {
                base.ViewDidLoad();
                this.Title = initialModel.TopicName;

                View.Frame = UIScreen.MainScreen.Bounds;
                View.BackgroundColor = UIColor.White;
                View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                table = new UITableView(new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height));

                Action<ForumTopicModel> skaters = new Action<ForumTopicModel>(UpdateAdapter);
                Forum.PullForumTopic(SettingsMobile.Instance.User.MemberId.ToString(), SettingsMobile.Instance.User.LoginId.ToString(), initialModel.TopicId, skaters);
                // Perform any additional setup after loading the view
                loading = new LoadingView();
                loading.ShowActivity("loading topic");

                var button2 = new UIBarButtonItem(UIBarButtonSystemItem.Reply, (sender, args) =>
                {
                    ReplyForumTopicViewController add = new ReplyForumTopicViewController(initialModel.TopicId, initialModel.TopicName);
                    this.NavigationController.PushViewController(add, true);

                });
                this.NavigationItem.SetRightBarButtonItem(button2, false);


                source = new TopicPostsTableView(initialArray, this.NavigationController);
                table.Source = source;
                //table.RowHeight = 50;

                this.NavigationItem.BackBarButtonItem = new UIBarButtonItem();
                this.NavigationItem.BackBarButtonItem.Title = "Topics";

                View.Add(table);
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
            }
        }
        void SelectedNavigationItem()
        {
            try
            {

                navigation.HideMenu();
                Action<ForumModel> skaters = new Action<ForumModel>(UpdateAdapter);
                Forum.PullForumTopics(SettingsMobile.Instance.User.MemberId.ToString(), SettingsMobile.Instance.User.LoginId.ToString(), "league", initialModel.Groups[navigation.SelectedIndex].GroupId, 0, 0, 30, skaters);
                // Perform any additional setup after loading the view
                loading = new LoadingView();
                loading.ShowActivity("loading group posts");

            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
            }
        }
        public override void ViewDidLoad()
        {
            try
            {
                base.ViewDidLoad();
                this.Title = "Reply to " + initialModel.TopicTitle;

                View.Frame = UIScreen.MainScreen.Bounds;
                View.BackgroundColor = UIColor.White;
                View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;


                UIScrollView scroll = new UIScrollView(new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height));
                scroll.ContentSize = new SizeF(View.Bounds.Width, 500);

                UILabel groupLbl = new UILabel(new RectangleF(10, 15, 200, 25));
                groupLbl.Text = "Title: ";
                scroll.AddSubview(groupLbl);
                UILabel groupNameLbl = new UILabel(new RectangleF(60, 15, 200, 25));
                groupNameLbl.Text = initialModel.TopicTitle;
                scroll.AddSubview(groupNameLbl);

                UILabel messageLbl = new UILabel(new RectangleF(10, 50, View.Bounds.Width, 25));
                messageLbl.Text = "Message:";
                scroll.AddSubview(messageLbl);

                messageTxt = new UITextView(new RectangleF(5, 80, View.Bounds.Width - 10, 200));

                messageTxt.Layer.BorderWidth = 1;
                messageTxt.Layer.MasksToBounds = true;
                messageTxt.Layer.CornerRadius = 8;
                messageTxt.Layer.BorderColor = UIColor.Gray.CGColor;
                scroll.AddSubview(messageTxt);

                warningTxt = new UILabel(new RectangleF(10, 290, View.Bounds.Width - 20, 35));
                warningTxt.TextColor = UIColor.Red;
                scroll.AddSubview(warningTxt);

                var button2 = new UIBarButtonItem("Send", UIBarButtonItemStyle.Plain, (sender, args) =>
                {
                    loading = new LoadingView();
                    loading.ShowActivity("sending message");
                    initialModel.DatePosted = DateTime.UtcNow;
                    initialModel.MemberId = SettingsMobile.Instance.User.MemberId.ToString();
                    initialModel.Text = messageTxt.Text;
                    initialModel.ForumType = "league";
                    initialModel.UserId = SettingsMobile.Instance.User.LoginId.ToString();
                    bool isSuccuessful = Forum.ReplyToTopic(initialModel);
                    loading.Hide();
                    
                    this.NavigationController.PopViewControllerAnimated(true);
                    
                });
                this.NavigationItem.SetRightBarButtonItem(button2, false);



                View.AddSubview(scroll);
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
            }
        }
 void loginBtn_TouchUpInside(object sender, EventArgs e)
 {
     try
     {
         loading = new LoadingView();
         loading.ShowActivity("logging in");
         SettingsMobile.Instance.User.UserName = userNameTxt.Text;
         SettingsMobile.Instance.User.Password = passwordTxt.Text;
         bool authenticate = User.Authenticate(new UserMobile() { UserName = userNameTxt.Text, Password = passwordTxt.Text });
         loading.Hide();
         if (authenticate)
         {
             this.NavigationController.PushViewController(new MainViewController(), true);
         }
         else
         {
             passwordTxt.Text = "";
             warningTxt.Text = "Wrong login details. Try Again.";
         }
     }
     catch (Exception exception)
     {
         ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
     }
 }
        void loginBtn_TouchUpInside(object sender, EventArgs e)
        {
            try
            {
                if (userNameTxt.Text.Length < 5)
                    userNameTxt.Layer.BorderColor = UIColor.Red.CGColor;
                else
                    userNameTxt.Layer.BorderColor = UIColor.Purple.CGColor;

                if (passwordTxt.Text.Length < 5)
                    passwordTxt.Layer.BorderColor = UIColor.Red.CGColor;
                else
                    passwordTxt.Layer.BorderColor = UIColor.Purple.CGColor;

                if (derbyNameTxt.Text.Length < 3)
                    derbyNameTxt.Layer.BorderColor = UIColor.Red.CGColor;
                else
                    derbyNameTxt.Layer.BorderColor = UIColor.Purple.CGColor;

                if (firstNameTxt.Text.Length < 3)
                    firstNameTxt.Layer.BorderColor = UIColor.Red.CGColor;
                else
                    firstNameTxt.Layer.BorderColor = UIColor.Purple.CGColor;

                if (userNameTxt.Text.Length > 4 && passwordTxt.Text.Length > 4 && derbyNameTxt.Text.Length > 2 && firstNameTxt.Text.Length > 2)
                {
                    loading = new LoadingView();
                    loading.ShowActivity("signing up");
                    SettingsMobile.Instance.User.UserName = userNameTxt.Text;
                    SettingsMobile.Instance.User.Password = passwordTxt.Text;
                    var authenticate = User.SignUp(new UserMobile() { IsConnectedToDerby = swith.On, UserName = userNameTxt.Text, Password = passwordTxt.Text, FirstName = firstNameTxt.Text, DerbyName = derbyNameTxt.Text, Position = 1, Gender = 1 });
                    loading.Hide();
                    if (authenticate.DidSignUp)
                    {
                        SettingsMobile.Instance.User = authenticate;
                        new SqlFactory().DeleteProfile().InsertProfile(new Mobile.Database.Account.SqlAccount(authenticate));
                        this.NavigationController.PushViewController(new MainViewController(), true);
                    }
                    else
                    {
                        warningTxt.Text = authenticate.Error;
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
            }
        }