//public smContentLibrary UpdateContentOnSchedular(int contentId, int UserId, int ImpersonateId, int IndustryId) //{ // smContentLibrary library = (from x in base.Context.Set<smContentLibrary>() // where x.ContentId == contentId // select x).FirstOrDefault<smContentLibrary>(); // string title = library.Title; // foreach (IGrouping<string, smContentLibrary> grouping in (from x in // (from x in base.Context.Set<smContentLibrary>() // where (((x.CategoryId == IndustryId) && !x.IsDeleted) && x.IsActive) && (x.SocialMedia != "Rss") // select x).ToList<smContentLibrary>() // group x by x.Title).Distinct<IGrouping<string, smContentLibrary>>()) // { // foreach (smContentLibrary library2 in grouping) // { // if (library2.Title == title) // { // smContentstatus contentstatus = new smContentstatus // { // ContentId = library2.ContentId, // UserId = UserId, // IsDeleted = true // }; // if (ImpersonateId != 0) // { // contentstatus.DeletedBy = ImpersonateId; // } // else // { // contentstatus.DeletedBy = UserId; // } // contentstatus.DeletedDate = DateTime.UtcNow; // base.Context.Set<smContentstatus>().Add(contentstatus); // base.Context.SaveChanges(); // } // } // } // return library; //} public smContentLibrary UpdateContentOnSchedular(int contentId, int UserId, int ImpersonateId, int IndustryId) { smContentLibrary library = (from x in base.Context.Set <smContentLibrary>() where x.ContentId == contentId select x).FirstOrDefault <smContentLibrary>(); string title = library.Title; foreach (IGrouping <string, smContentLibrary> grouping in (from x in (from x in base.Context.Set <smContentLibrary>() where (((x.CategoryId == IndustryId) && !x.IsDeleted) && x.IsActive) && (x.SocialMedia != "Rss") select x).ToList <smContentLibrary>() group x by x.Title).Distinct <IGrouping <string, smContentLibrary> >()) { foreach (smContentLibrary library2 in grouping) { if (library2.Title == title) { smContentstatus contentstatus = new smContentstatus { ContentId = library2.ContentId, UserId = UserId, IsDeleted = true }; if (ImpersonateId != 0) { contentstatus.DeletedBy = ImpersonateId; } else { contentstatus.DeletedBy = UserId; } contentstatus.DeletedDate = DateTime.UtcNow; base.Context.Set <smContentstatus>().Add(contentstatus); base.Context.SaveChanges(); } } } return(library); }
//public List<smContentLibrary> GetCategoryListforcalender(int IndustryId, List<smPreference> list) //{ // List<smContentLibrary> library = Context.Set<smContentLibrary>().Where(x => x.CategoryId == IndustryId && x.IsActive == true && x.IsDeleted == false && x.SocialMedia != "Rss").ToList(); // List<smContentLibrary> smContentLibrary = new List<smContentLibrary>(); // if (list.Count != 0) // { // foreach (var item in library) // { // if (!string.IsNullOrEmpty(item.SubIndustryName)) // { // List<smPreference> catg = list.Where(x => x.Preference.ToLower() == item.SubIndustryName.ToLower()).ToList(); // smContentLibrary.Add(item); // } // } // } // return smContentLibrary; //} public List <smContentLibrary> GetCategoryListforcalender(int IndustryId, List <smPreference> list, int userId, string data) { var myvar = from a in Context.Set <smContentLibrary>().Where(x => x.CategoryId == IndustryId && x.IsActive == true && !x.IsDeleted) join b in Context.Set <smSocialMediaProfile>().Where(x => x.UserId == userId) on a.SocialMedia equals b.SocialMedia select new { a }; // var rssContent = Context.Set<smContentLibrary>().Where(x => x.CategoryId == IndustryId && x.IsActive && !x.IsDeleted && x.SocialMedia != "Rss").ToList(); List <smContentLibrary> list2 = new List <smContentLibrary>(); foreach (var item in myvar) { list2.Add(item.a); } // list2.AddRange(rssContent); //List<smContentLibrary> list2 = (from x in base.Context.Set<smContentLibrary>() // /// where (((x.CategoryId == IndustryId) && x.IsActive) && !x.IsDeleted) && (x.SocialMedia != "Rss") ///old // where (((x.CategoryId == IndustryId) && x.IsActive) && !x.IsDeleted) /// new SRohit // select x).ToList<smContentLibrary>(); List <smContentstatus> list3 = (from x in base.Context.Set <smContentstatus>() where x.UserId == userId select x).ToList <smContentstatus>(); List <smContentLibrary> source = new List <smContentLibrary>(); if (list.Count != 0) { //using (List<smContentLibrary>.Enumerator enumerator = list2.GetEnumerator()) //{ // while (enumerator.MoveNext()) // { // Func<smPreference, bool> predicate = null; // smContentLibrary item = enumerator.Current; // if (!string.IsNullOrEmpty(item.SubIndustryName)) // { // if (predicate == null) // { // predicate = x => x.Preference.ToLower() == item.SubIndustryName.ToLower(); // } // list.Where<smPreference>(predicate).ToList<smPreference>(); // source.Add(item); // } // } //} var preferenceList = list.Select(x => x.Preference).ToList(); source = list2.Where(m => preferenceList.Contains(m.SubIndustryName)).ToList(); } List <smContentLibrary> second = new List <smContentLibrary>(); List <smContentLibrary> list6 = new List <smContentLibrary>(); if (list3.Count != 0) { using (List <smContentstatus> .Enumerator enumerator2 = list3.GetEnumerator()) { while (enumerator2.MoveNext()) { Func <smContentLibrary, bool> func2 = null; smContentstatus it = enumerator2.Current; if (func2 == null) { func2 = x => x.ContentId == it.ContentId; } smContentLibrary library = source.Where <smContentLibrary>(func2).FirstOrDefault <smContentLibrary>(); second.Add(library); list6 = source.Except <smContentLibrary>(second).ToList <smContentLibrary>(); } // return list6; var AddedList = Context.Set <smPost>().Where(x => x.UserId == userId).Select(x => x.ContentId).ToList(); var OldList = list6.Where(e => AddedList.Contains(e.ContentId)); var NewList = list6.Where(e => !AddedList.Contains(e.ContentId)); if (!String.IsNullOrEmpty(data)) { if (data == "0") { return(OldList.ToList()); } else { return(NewList.ToList()); } } } } var AddedLists = Context.Set <smPost>().Where(x => x.UserId == userId).Select(x => x.ContentId).ToList(); var OldLists = source.Where(e => AddedLists.Contains(e.ContentId)); var NewLists = source.Where(e => !AddedLists.Contains(e.ContentId)); if (!String.IsNullOrEmpty(data)) { if (data == "0") { return(OldLists.ToList()); } else { return(NewLists.ToList()); } } else { return(source); } }