public async Task <OwnCarousel> GetAds(int id) { Lesson lessonCatalog; using (var dctx = new EF.MindSageDataModelsContainer()) { lessonCatalog = await dctx.Lessons .Include("Advertisements") .FirstOrDefaultAsync(it => it.Id == id); } if (lessonCatalog == null) { return(null); } var adsUrls = (lessonCatalog.Advertisements ?? Enumerable.Empty <Advertisement>()) .Where(it => !it.RecLog.DeletedDate.HasValue) .Select(it => it.ImageUrl); var result = new OwnCarousel { owl = adsUrls.Select(it => new OwnCarousel.OwnItem { item = $"<div class='item'><img src='{ it }' /></div>" }) }; return(result); }
public async Task <OwnCarousel> GetAds(int id) { EF.CourseCatalog courseCatalog; using (var dctx = new EF.MindSageDataModelsContainer()) { courseCatalog = await dctx.CourseCatalogs .Include("Semesters.Units.Lessons.Advertisements") .Include("Semesters.Units.Lessons.TopicOfTheDays") .FirstOrDefaultAsync(it => it.Id == id); } if (courseCatalog == null) { return(null); } var adsUrls = courseCatalog?.Advertisements?.Split(new string[] { "#;" }, StringSplitOptions.RemoveEmptyEntries) ?? Enumerable.Empty <string>(); var result = new OwnCarousel { owl = adsUrls.Select(it => new OwnCarousel.OwnItem { item = $"<div class='item'><img src='{ it }' /></div>" }) }; return(result); }