public async Task <StripDomain> CreateAsync(StripDomain stripDomain) { StripEntity stripEntity = Mapper.Map <StripEntity>(stripDomain); EntityEntry <StripEntity> entity = await DbSet.AddAsync(stripEntity); return(Mapper.Map <StripDomain>(entity.Entity)); }
private async Task SendLocalisedStripNotificationsAsync(StripDomain strip) { StripDomain stripToNotify = await _stripManager.GetStripByNumberAsync(strip.Number); ChapterDomain chapter = await _mediator.Send(new GetChapterQuery(stripToNotify.Category)); Dictionary <string, string> templateParams = new() {
private static Uri GetImagePath(StripDomain strip, FileFormat fileType) { var filePath = fileType switch { FileFormat.Png => strip.Url + ".png", FileFormat.Gif => strip.Url + ".gif", _ => strip.Url + ".jpg", }; return(new Uri(filePath)); }
public async Task <IActionResult> GetStrip(int number) { try { StripDomain stripData = await _mediator.Send(new GetStripQuery(number)); StripOutputDTO strip = _mapper.Map <StripOutputDTO>(stripData); return(Ok(strip)); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } catch { throw; } }
public static async Task <List <StripDomain> > ParseAsync(Uri url, ChaptersDomain chapters, IEnumerable <StripDomain> stripsInDatabase) { List <StripDomain> strips = new(); HtmlWeb web = new(); HtmlDocument htmlDoc = web.Load(url); foreach (ChapterDomain chapter in chapters) { IEnumerable <HtmlNode> nodes = htmlDoc.DocumentNode.SelectNodes("//li/a").Where(w => w.ParentNode.ParentNode.ParentNode.ParentNode.SelectSingleNode(".//a").Id == chapter.Category); foreach (HtmlNode node in nodes) { StripDomain strip = await ExtractStripAsync(node, chapter, stripsInDatabase); if (strip != null) { strips.Add(strip); } } } return(strips); }
private static async Task <bool> GetFileTypeAsync(StripDomain strip) { Uri filePath; bool formatFound; if (strip.Number < 1081) { filePath = GetImagePath(strip, FileFormat.Gif); formatFound = await CheckFileFormatAsync(filePath); } else { filePath = GetImagePath(strip, FileFormat.Png); formatFound = await CheckFileFormatAsync(filePath); } if (!formatFound) { filePath = GetImagePath(strip, FileFormat.Jpeg); formatFound = await CheckFileFormatAsync(filePath); } if (!formatFound) { if (strip.Number >= 1081) { filePath = GetImagePath(strip, FileFormat.Gif); formatFound = await CheckFileFormatAsync(filePath); } else { filePath = GetImagePath(strip, FileFormat.Png); formatFound = await CheckFileFormatAsync(filePath); } } strip.Url = filePath; return(formatFound); }