public ActionResult Index(string facebookID, string orientation) { PostModel model = new PostModel(); return base.View(model.GetAll(facebookID, orientation).ToList<PostModel>()); }
public IQueryable<PostModel> GetAll(string facebookID, string orientation) { List<PostModel> list = new List<PostModel>(); string str = string.Empty; string accessToken = string.Empty; str = new oAuthFacebook().AuthorizationLinkGet(); accessToken = this.GetAccessToken(); int count = Convert.ToInt32(WebConfiguration.Current.FacebookNumberToReturn); count = 3; Dictionary<int, object> posts = new Dictionary<int, object>(); posts = this.GetPosts(accessToken, facebookID); foreach (dynamic obj2 in posts) { try { dynamic obj3 = obj2.Value; PostModel item = new PostModel { Orientation = orientation, FacebookID = facebookID }; try { item.Caption = (string) obj3.caption; } catch { item.Caption = string.Empty; } try { item.Picture = (string) obj3.picture; } catch { item.Picture = string.Empty; } try { item.Story = (string) obj3.story; } catch { item.Story = string.Empty; } try { item.Message = (string) obj3.message; } catch { item.Message = string.Empty; } try { item.Link = (string) obj3.link; } catch { item.Link = string.Empty; } try { item.Icon = (string) obj3.icon; } catch { item.Icon = string.Empty; } try { item.FCTime = (DateTime) DateTime.Parse(obj3.created_time); } catch { item.FCTime = DateTime.Now; } try { item.FUTime = (DateTime) DateTime.Parse(obj3.updated_time); } catch { item.FUTime = DateTime.Now; } try { item.FName = (string) obj3.name; } catch { item.FName = string.Empty; } try { item.Type = (string) obj3.type; } catch { item.Type = string.Empty; } try { item.StatusType = (string) obj3.status_type; } catch { item.StatusType = string.Empty; } if (!string.IsNullOrEmpty(item.Link)) { list.Add(item); } } catch (Exception) { } } List<string> typeList = WebConfiguration.Current.FaceBookType.Split(new char[] { ',' }).ToList<string>(); List<PostModel> source = (from o in list where typeList.Contains(o.Type) orderby o.FCTime descending select o).ToList<PostModel>(); if (source.Count > count) { return source.GetRange(0, count).AsQueryable<PostModel>(); } return source.AsQueryable<PostModel>(); }