public IList<MemberSeeds> GetAllSeedsByParrentId(string ParrentId, string counter) { IList<MemberSeeds> lstMemberSeeds = new List<MemberSeeds>(); SeedAction objSeed = new SeedAction(); int getCounter = Convert.ToInt32(counter) + 1; IList<Seed> seedData = (objSeed.GetSeedsByParrentSeedID(ParrentId)).Take(getCounter).OrderBy(x => x.createDate).ToList(); //int i = 0; foreach (Seed s in seedData) { MemberSeeds objMemberSeed = new MemberSeeds(); string imgPath = "No Image"; objMemberSeed.SeedID = s.id.ToString(); objMemberSeed.Title = s.title; if (s.Media != null && s.Media.Where(x => x.type.Equals("Image")).Count() > 0) { imgPath = s.Media.Where(x => x.type.Equals("Image")).OrderByDescending(x => x.dateUploaded).FirstOrDefault().path; imgPath = imgPath.Substring(imgPath.LastIndexOf('/')); if (imgPath.Length > 1) { imgPath = System.Configuration.ConfigurationManager.AppSettings["RootURL"].ToString() + "/UploadedMedia" + imgPath; } else { imgPath = "No Image"; } } objMemberSeed.Path = imgPath; if (s.Location.City != null) { objMemberSeed.City = s.Location.City.name; } if (s.Location.City.Region != null) { objMemberSeed.State = s.Location.City.Region.code; } if (s.Location != null) { objMemberSeed.Zip = s.Location.zipcode; objMemberSeed.Latitude = s.Location.localLat.ToString(); objMemberSeed.Longitude = s.Location.localLong.ToString(); } objMemberSeed.CreateDate = s.createDate.ToString(); lstMemberSeeds.Add(objMemberSeed); } //if (seedData.Count < 1) //{ // MemberSeeds objMemberSeed = new MemberSeeds(); // objMemberSeed.SeedID = "No Matching Seeds Found##No Matching Seeds Found"; // lstMemberSeeds.Add(objMemberSeed); //} return lstMemberSeeds; }