public async Task <PageDto> GetPageByIdAsync(Guid id) { PageDto page = PageConverter.Convert(await _pageRepo.GetByIdAsync(id)); page.Blocks = BlockConverter.Convert(await _blockRepo.GetByPageIdAsync(id)); page.CourseName = _courseRepo.GetByIdAsync(page.CourseId).Result.Name; return(page); }
public async Task <CourseDto> GetCourseByIdAsync(Guid id) { CourseDto course = CourseConverter.Convert(await _courseRepo.GetByIdAsync(id)); course.DirectionName = _directionRepo.GetByIdAsync(course.DirectionId).Result.Name; course.Groups = GroupConverter.Convert(await _groupRepo.GetByCourseIdAsync(id)); course.Pages = PageConverter.Convert(await _pageRepo.GetByCourseIdAsync(id)); return(course); }
private void ProcessPages(string exhibitId, CancellationToken token, ITransactionDataAccess dataAccess, Dictionary <MediaDto, string> mediaToFilePath) { var fetchedMedia = mediaDataFetcher.CombineMediasAndFiles(dataAccess, mediaToFilePath); if (token.IsCancellationRequested) { return; } var exhibit = dataAccess.Exhibits().GetExhibit(exhibitId); foreach (var pageDto in pageItems) { var dbPage = PageConverter.Convert(pageDto); AddContentToPage(dbPage, pageDto, fetchedMedia); // Add Page with content to the exhibit exhibit.Pages.Add(dbPage); } // Rearrange additional information pages var pagesToBeRemoved = new List <Page>(); foreach (var pageDto in pageItems) { if (pageDto.AdditionalInformationPages.Count > 0) { foreach (var existingPageWithInfo in exhibit.Pages) { if (pageDto.Id == existingPageWithInfo.IdForRestApi) { foreach (var pageId in pageDto.AdditionalInformationPages) { foreach (var pageToBeAdded in exhibit.Pages) { if (pageToBeAdded.IdForRestApi == pageId) { existingPageWithInfo.AdditionalInformationPages.Add(pageToBeAdded); pagesToBeRemoved.Add(pageToBeAdded); break; } } } } } } } foreach (var pageToBeRemoved in pagesToBeRemoved) { exhibit.Pages.Remove(pageToBeRemoved); } exhibit.DetailsDataLoaded = true; }
public byte[] Save() { foreach (var page in pages) { var isLastPage = page == pages.Last(); document.MainDocumentPart.Document.Body.Append(PageConverter.Convert(page, this, document, isLastPage)); } using (memoryStream) using (document) document.Close(); return(memoryStream.ToArray()); }
private void AddContentToPage(Page dbPage, PageDto pageDto, FetchedMediaData fetchedMedia) { if (pageDto != null && dbPage != null) { PageConverter.Convert(pageDto, dbPage); switch (dbPage) { case ImagePage imagePage: var image = fetchedMedia.Images.SingleOrDefault(x => x.IdForRestApi == pageDto.Image); imagePage.Image = image ?? BackupData.BackupImage; break; case TextPage textPage: break; case TimeSliderPage timeSliderPage: var fetchedImages = fetchedMedia.Images; if (fetchedImages.Count > 0) { Debug2.Assert(timeSliderPage.SliderImages.Count == pageDto.Images.Count); for (var i = 0; i < timeSliderPage.SliderImages.Count; i++) { var imageId = pageDto.Images[i].Image; var dbImage = fetchedImages.FirstOrDefault(img => img.IdForRestApi == imageId); timeSliderPage.SliderImages[i].Image = dbImage; } } else { timeSliderPage.SliderImages.Add(new TimeSliderPageImage { Page = timeSliderPage, Image = BackupData.BackupImage }); } break; } var audio = fetchedMedia.Audios.SingleOrDefault(x => x.IdForRestApi == pageDto.Audio); if (audio != null) { dbPage.Audio = audio; } } }
public async Task <bool> UpdatePageAsync(PageDto item) { return(await _pageRepo.UpdateAsync(PageConverter.Convert(item))); }
public async Task <PageDto> CreatePageAsync(PageDto item) { return(PageConverter.Convert(await _pageRepo.CreateAsync(PageConverter.Convert(item)))); }
public async Task <List <PageDto> > GetPageByCourseIdAsync(Guid id) { return(PageConverter.Convert(await _pageRepo.GetByCourseIdAsync(id))); }
public async Task <List <PageDto> > GetAllPageAsync() { return(PageConverter.Convert(await _pageRepo.GetAllAsync())); }