/*GetAllPosts:returns all the posts for a given category,subcategory,localeid, or areaId * we will add methods that take into account the other combinations */ //cID can be either categoryID or subcategoryID and lID can be either localeID or areaID public static IEnumerable <Post> GetAllPosts(string cID, string lID) { var Posts = from post in db.Posts where post.locale == lID && post.category == cID select post; //bizlogic to sort according to most recent time var orderedPosts = Biz.OrderPosts(Posts.ToList()); return(orderedPosts); }
/* GetAllExpiredPosts: returns all the expired posts for a specific user */ public static IEnumerable <Post> GetAllExpiredPosts(string userID) { var Posts = from post in db.Posts where post.isDeletedOrHidden && post.ownerID == userID select post; //bizlogic to sort according to most recent time var orderedPosts = Biz.OrderPosts(Posts.ToList()); return(orderedPosts); }
public void Test_orderPosts() { List <String> listPosts = new List <String> { "14", "24", "52" }; var posts = from post in db.Posts select post; var output = Biz.OrderPosts(posts.ToList()); List <String> postNames = new List <String>(); foreach (var item in output) { postNames.Add(item.postNumber.ToString()); } CollectionAssert.AreEqual(listPosts, postNames); }