public AddPost() { InitializeComponent(); try { progressIndicator = SystemTray.ProgressIndicator; progressIndicator = new ProgressIndicator(); SystemTray.SetProgressIndicator(this, progressIndicator); progressIndicator.IsIndeterminate = true; progressIndicator.Text = "Pulling Categories..."; forumModel = (ForumModel)(App.Current as App).SecondPageObject; Groups.ItemsSource = forumModel.Groups; currentGroup = forumModel.Groups.Where(x => x.GroupId == forumModel.GroupId).FirstOrDefault(); if (currentGroup != null) { ForumGroupName.Text = currentGroup.GroupName; //groupName.Text = currentGroup.GroupName; Groups.SelectedItem = currentGroup; Categories.ItemsSource = currentGroup.Categories; } } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.WP8); } }
//long currentGroupId = 0; public ForumMain() { InitializeComponent(); try { TopicsList.ItemRealized += TopicsList_ItemRealized; progressIndicator = SystemTray.ProgressIndicator; progressIndicator = new ProgressIndicator(); SystemTray.SetProgressIndicator(this, progressIndicator); progressIndicator.IsIndeterminate = true; progressIndicator.Text = "Pulling Forum..."; if ((App.Current as App).SecondPageObject != null) { try { forumModel = (ForumModel)(App.Current as App).SecondPageObject; (App.Current as App).SecondPageObject = null; forumModel.CategoryId = 0; ForumPivot.SelectedIndex = 1; } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.WP8); } } CurrentTopics = new ObservableCollection<ForumTopicModel>(); PullGroups(); } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.WP8); } }
public ForumTopicsViewController() { initialModel = new ForumModel(); initialArray = new List<ForumTopicModel>(); }
void UpdateAdapter(ForumModel skaters) { try { initialModel = skaters; var group = initialModel.Groups.Where(x => x.GroupId == initialModel.GroupId).FirstOrDefault(); currentGroupName = group.GroupName; initialArray.Clear(); if (group != null) initialArray.AddRange(group.Topics); RootElement navHead = new RootElement("Navigation"); Section section = new Section("Groups"); List<StringElement> groups = new List<StringElement>(); for (int i = 0; i < skaters.Groups.Count; i++) { groups.Add(new StringElement(skaters.Groups[i].GroupName)); } section.AddAll(groups); navHead.Add(section); InvokeOnMainThread(() => { try { table.ReloadData(); loading.Hide(); navigation.HideMenu(); this.Title = group.GroupName + " Posts"; navigation.NavigationRoot = navHead; } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.iPhone); } }); SettingsMobile.Instance.CurrentForumId = skaters.ForumId; } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.iPhone); } }
public JsonResult Posts(string mid, string uid, string t, string gid, string cid, int p, int c) { ForumModel model = new ForumModel(); try { var mem = MemberCache.GetMemberDisplay(new Guid(mid)); if (new Guid(uid) == mem.UserId) { long gId = 0; if (!String.IsNullOrEmpty(gid)) gId = Convert.ToInt64(gid); Guid forumId = MemberCache.GetForumIdForMemberLeague(new Guid(mid)); var topics = Forum.GetForumTopics(new Guid(mid), forumId, (ForumOwnerTypeEnum)Enum.Parse(typeof(ForumOwnerTypeEnum), t), gId, c, p, false); model.ForumId = forumId; model.GroupId = gId; for (int i = 0; i < topics.GroupTopics.Count; i++) { ForumGroupModel group = new ForumGroupModel(); group.GroupId = topics.GroupTopics[i].GroupId; group.GroupName = topics.GroupTopics[i].GroupName; group.Categories = topics.Categories; for (int j = 0; j < topics.GroupTopics[i].Topics.Count; j++) { ForumTopicModel topic = new ForumTopicModel(); if (topics.GroupTopics[i].Topics[j].Category != null) { topic.Category = topics.GroupTopics[i].Topics[j].Category.CategoryName; topic.CategoryId = topics.GroupTopics[i].Topics[j].Category.CategoryId; } if (topics.GroupTopics[i].Topics[j].LastPostByMember != null) { topic.LastPostById = topics.GroupTopics[i].Topics[j].LastPostByMember.MemberId; topic.LastPostByName = topics.GroupTopics[i].Topics[j].LastPostByMember.DerbyName; } topic.PostCount = topics.GroupTopics[i].Topics[j].Replies; if (topics.GroupTopics[i].Topics[j].CreatedByMember != null) { topic.StartedById = topics.GroupTopics[i].Topics[j].CreatedByMember.MemberId; topic.StartedByName = topics.GroupTopics[i].Topics[j].CreatedByMember.DerbyName; } topic.StartedRelativeTime = topics.GroupTopics[i].Topics[j].CreatedHuman; topic.TopicId = topics.GroupTopics[i].Topics[j].TopicId; topic.ForumId = forumId; topic.HasRead = topics.GroupTopics[i].Topics[j].IsRead; topic.IsLocked = topics.GroupTopics[i].Topics[j].IsLocked; topic.IsManagerOfTopic = topics.GroupTopics[i].Topics[j].IsManagerOfTopic; topic.IsPinned = topics.GroupTopics[i].Topics[j].IsPinned; topic.IsWatching = topics.GroupTopics[i].Topics[j].IsWatching; topic.TopicName = topics.GroupTopics[i].Topics[j].TopicTitle; topic.ViewCount = topics.GroupTopics[i].Topics[j].ViewCount; topic.LastPostRelativeTime = topics.GroupTopics[i].Topics[j].LastModifiedHuman; group.Topics.Add(topic); } group.UnreadTopicsCount = group.Topics.Where(x => x.HasRead == false).Count(); model.Groups.Add(group); } if (!String.IsNullOrEmpty(cid)) model.CategoryId = Convert.ToInt64(cid); } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return Json(model, JsonRequestBehavior.AllowGet); }
/// <summary> /// returns the forum model from the api. /// </summary> /// <param name="model"></param> void ReturnForumModel(ForumModel model) { try { ForumGroupModel currentGroup = null; var pulledTopics = model.Groups.Where(x => x.GroupId == forumModel.GroupId).FirstOrDefault(); if (lastPagePulled == 0) { forumModel = model; currentGroup = forumModel.Groups.Where(x => x.GroupId == forumModel.GroupId).FirstOrDefault(); CurrentTopics.Clear(); for (int i = 0; i < currentGroup.Topics.Count; i++) CurrentTopics.Add(currentGroup.Topics[i]); } else { currentGroup = model.Groups.Where(x => x.GroupId == forumModel.GroupId).FirstOrDefault(); for (int i = 0; i < currentGroup.Topics.Count; i++) CurrentTopics.Add(currentGroup.Topics[i]); } Dispatcher.BeginInvoke(delegate { GroupNamesList.ItemsSource = model.Groups; if (currentGroup != null) { TopicsList.ItemsSource = CurrentTopics; CategoryNamesList.ItemsSource = currentGroup.Categories; } progressIndicator.IsVisible = false; isLoading = false; }); } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.WP8); } }