internal static string[] GetAllCategoryNames() { ForumData forumData = new ForumData(); var allCategories = forumData.Categories.Select(c => c.Name).ToArray(); return(allCategories); }
public static Category GetCategory(int categoryId) { ForumData forumData = new ForumData(); Category category = forumData.Categories.Find(c => c.Id == categoryId); return(category); }
internal static User GetUser(string username) { ForumData forumData = new ForumData(); var user = forumData.Users.FirstOrDefault(u => u.Username == username); return(user); }
public static User GetUser(string username) { ForumData forumData = new ForumData(); User user = forumData.Users.Find(u => u.Username == username); return(user); }
internal static User GetUser(int id) { ForumData forumData = new ForumData(); var user = forumData.Users.FirstOrDefault(u => u.Id == id); return(user); }
public static IEnumerable <Post> GetPostsByCategory(string categoryName) { ForumData forumData = new ForumData(); ICollection <int> postIds = forumData.Categories.First(c => c.Name == categoryName).PostIds; IEnumerable <Post> posts = forumData.Posts.Where(p => postIds.Contains(p.Id)); return(posts); }
public static PostViewModel GetPostViewModel(string postTitle) { ForumData forumData = new ForumData(); Post post = forumData.Posts.Find(p => p.Title == postTitle); PostViewModel postViewModel = new PostViewModel(post); return(postViewModel); }
public static PostViewModel GetPostViewModel(int postId) { var forumData = new ForumData(); var post = forumData.Posts.Find(p => p.Id == postId); PostViewModel pmv = new PostViewModel(post); return(pmv); }
public static PostViewModel GetPostViewModel(int postId) { var forumdata = new ForumData(); Post post = forumdata.Posts.SingleOrDefault(p => p.Id == postId); return(new PostViewModel(post)); }
internal static Category GetCategory(int categoryId) { ForumData forumData = new ForumData(); Category category = forumData.Categories.Find(u => u.Id == categoryId); return(category); }
internal static User GetUser(int userId) { var forumData = new ForumData(); User user = forumData.Users.Find(u => u.Id == userId); return(user); }
internal static User GetUser(string username, ForumData forumData) { // ForumData forumData = new ForumData(); User user = forumData.Users.Find(u => u.Username == username); return(user); }
public static IEnumerable <Post> GetPostByCategory(int categoryId) { var forumData = new ForumData(); var postIds = forumData.Categories.SingleOrDefault(c => c.Id == categoryId).Posts; return(forumData.Posts .Where(p => postIds.Contains(p.Id))); }
public static PostViewModel GetPostViewModel(int postId) { ForumData forumData = new ForumData(); Post post = forumData.Posts.Find(x => x.Id.Equals(postId)); PostViewModel pvm = new PostViewModel(post); return(pvm); }
internal static User GetUser(string username) { ForumData forumData = new ForumData(); User user = forumData.Users.Find(x => x.Username == username); return(user); }
internal static User GetUser(int userId) { ForumData forumData = new ForumData(); User user = forumData.Users.Find(x => x.Id == userId); return(user); }
public static PostViewModel GetPostViewModel(int postId) { ForumData forumData = new ForumData(); Post post = forumData.Posts.Find(p => p.Id == postId); PostViewModel pvm = new PostViewModel(post); return(pvm); }
public static IEnumerable <Post> GetPostsByCategory(int categoryId) { ForumData forumdata = new ForumData(); Category category = forumdata.Categories.Single(c => c.Id == categoryId); List <Post> forumata1 = forumdata.Posts; return(forumata1.Where(p => category.PostIds.Contains(p.Id)).ToList()); }
public static IEnumerable <Post> GetPostsByCategory(int categoryId) { ForumData forumData = new ForumData(); var postIds = forumData.Categories.First(c => c.Id == categoryId).PostIds; IEnumerable <Post> posts = forumData.Posts.Where(p => postIds.Contains(p.Id)); return(posts); }
public static User GetUser(int userId) { ForumData forumData = new ForumData(); User user = forumData.Users.Find(u => u.Id == userId); return(user); }
private static void Main(string[] args) { var httpClient = new GenericHttpClient(); var forumData = new ForumData(httpClient); var forumClientApp = new ForumClientApp(forumData); forumClientApp.Start(); }
internal static string[] GetAllGategoryNames() { var allCategories = ForumData.GetInstance() .Categories .Select(c => c.Name) .ToArray(); return(allCategories); }
public static IEnumerable <Post> GetPostsByCategory(int categoryId) { ForumData forumData = new ForumData(); var postIds = forumData.Categories.First(x => x.Id.Equals(categoryId)).Posts; IEnumerable <Post> posts = forumData.Posts.Where(x => postIds.Contains(x.Id)); return(posts); }
internal static IEnumerable <Post> GetPostsByCategory(int categoryId) { ForumData forumData = new ForumData(); IEnumerable <Post> posts = forumData.Posts .Where(post => post.CategoryId == categoryId); return(posts); }
public static string[] GetAllGategoryNames() { string[] allCategoryNames = new ForumData() .Categories .Select(category => category.Name) .ToArray(); return(allCategoryNames); }
internal static IEnumerable <Post> GetPostsByCategory(int categoryId) { var postIds = ForumData.GetInstance().Categories .First(c => c.Id == categoryId).Posts.ToHashSet(); var posts = ForumData.GetInstance() .Posts.Where(p => postIds.Contains(p.Id)); return(posts); }
public static IEnumerable <Post> GetPostsByCategory(int categoryId) { ForumData forumdata = new ForumData(); var category = forumdata.Categories.Single(c => c.Id == categoryId); var posts = forumdata .Posts .Where(p => category.PostsIds.Contains(p.Id)).ToList(); return(posts); }
public static bool TryLogInUser(string username, string password) { if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password)) { return(false); } ForumData forumdata = new ForumData(); bool userExists = forumdata.Users.Any(u => u.Username == username && u.Password == password); return(userExists); }
internal static IList <ReplyViewModel> GetPostReplies(int postId) { var post = ForumData.GetInstance().Posts.Find(p => p.Id == postId); var replies = ForumData.GetInstance().Replies .Where(r => r.PostId == post.Id) .Select(r => new ReplyViewModel(r)) .ToList(); return(replies); }
public static bool TryLogInUser(string username, string password) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { return(false); } var forumData = new ForumData(); var usersExist = forumData.Users.Any(u => u.Username.Equals(username) && u.Password.Equals(password)); return(usersExist); }
protected AwfulForumPage(ForumData forum, int pageNumber, string url) { _pageNumber = pageNumber; this._forumID = default(int); if (forum != null) { this._forumID = forum.ID; this._parent = forum; } if (url == null) { this.Url = this.CreateUrl(forum, pageNumber); } else { this.Url = url; } }
public void FetchForumPage(ForumData forum, int pageNumber, Action<ForumPageData> action) { var url = new StringBuilder(); // http://forums.somethingawful.com/forumdisplay.php url.AppendFormat("{0}/{1}", Constants.BASE_URL, Constants.FORUM_PAGE_URI); // ?forumid=<FORUMID> url.AppendFormat("?forumid={0}", forum.ID); // &daysprune=30&perpage=30&posticon=0sortorder=desc&sortfield=lastpost url.Append("&daysprune=30&perpage=30&posticon=0sortorder=desc&sortfield=lastpost"); // &pagenumber=<PAGENUMBER> url.AppendFormat("&pagenumber={0}", pageNumber); var web = new WebGet(); web.LoadAsync(url.ToString(), (ar, doc) => { ForumPageData result = null; if (ar == ActionResult.Success) { result = AwfulForumParser.ParseForumPage(doc.Document); } action(result); }); }
public AwfulForumPage(ForumData forum, int pageNumber) : this(forum, pageNumber, null) { }
private string GetSubforumName(ForumData forum) { var mapping = App.Database.SubForumMappings .Where(map => map.ForumID == forum.ForumID) .FirstOrDefault(); if (mapping != null) return mapping.Subforum.Name; return "Other"; }
private string CreateUrl(ForumData forum, int pageNumber) { // http://forums.somethingawful.com/forumdisplay.php?forumid={0}&daysprune=15&perpage=40&posticon=0sortorder=desc&sortfield=lastpost&pagenumber={1} // var url = string.Format("{0}/{1}?forumid={2}&{3}&pagenumber={4}", BASE_URL, PAGE, forum.ID, PAGE_OPTIONS, pageNumber); Awful.Core.Event.Logger.AddEntry(string.Format("AwfulForumPage - Forum url: '{0}'", url)); return url; }
private void UpdateFavoritesMenu(ForumData forum) { var favoriteMenu = ApplicationBar.MenuItems[ADD_REMOVE_FAVORITES_MENU_INDEX] as IApplicationBarMenuItem; bool canExecute = this._toggleFavorites.CanExecute(forum); if (canExecute) { favoriteMenu.Text = this._toggleFavorites.Header; } }
private string CreateUrl(ForumData forum, int pageNumber) { // example: // http://forums.somethingawful.com/forumdisplay.php?forumid={0}&daysprune=15&perpage=40&posticon=0sortorder=desc&sortfield=lastpost&pagenumber={1} // var url = string.Format("{0}/{1}?forumid={2}&{3}&pagenumber={4}", Constants.BASE_URL, Constants.FORUM_PAGE_URI, forum.ID, Constants.FORUM_PAGE_QUERY, pageNumber); Logger.AddEntry(string.Format("AwfulForumPage - Forum url: '{0}'", url)); return url; }
private char GetForumAlphaGroup(ForumData forum) { string name = forum.ForumName.ToLower(); char c; if (name.Substring(0, 4).Equals("the ")) c = name[4]; else c = name[0]; if (alphabet.Contains(c)) return c; return '#'; }
public void RequestNewThreadAsync(ForumData forum, Action<ActionResult, AwfulThreadRequest> result) { if (_requestThread.IsBusy) { result(ActionResult.Busy, null); return; } RunWorkerCompletedEventHandler handler = null; handler = (obj, args) => { this._requestThread.RunWorkerCompleted -= new RunWorkerCompletedEventHandler(handler); if (args.Cancelled) { result(ActionResult.Cancelled, null); } else { NewThreadRequest request = args.Result as NewThreadRequest; if (request == null) result(ActionResult.Failure, null); else result(ActionResult.Success, request); } }; _requestThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(handler); _requestThread.RunWorkerAsync(forum); }
private string GroupBySubforum(ForumData forum) { var mapping = (forum as SAForum).Subforum; if (mapping != null) return mapping.Name; return "Other"; }
private char GroupByAlpha(ForumData forum) { string name = forum.ForumName.ToLower(); char c; if (name.Substring(0, 4).Equals("the ")) c = name[4]; else c = name[0]; if (ALPHABET.Contains(c)) return c; return '#'; }
public void AddForumToFavorites(ForumData forum) { AwfulForumFavorite favorite = new AwfulForumFavorite(); favorite.Profile = this; favorite.Forum = forum as AwfulForum; this.ForumFavorites.Add(favorite); }
public void RemoveForumFromFavorites(ForumData forum) { var favorite = from f in this.ForumFavorites where f.Forum == forum select f; this.ForumFavorites.Remove(favorite.SingleOrDefault()); }