private async Task RemoveAlreadySentedJob(ParseByJobLinkDto parseByJobLinkDto) { var splitedLinks = parseByJobLinkDto.JobLinks.Split(";").Select(x => x.Trim()).ToList(); List <string> existedJobs = await Context.BotSignalFlexJob .Where(x => x.Account.Email == parseByJobLinkDto.AccountEmail) .Select(x => x.JobLinks.Trim()) .ToListAsync(); parseByJobLinkDto.JobLinks = string.Join(";", splitedLinks.Where(x => !existedJobs.Contains(x.Trim()))); }
public async Task <IActionResult> ParseByJobLinks([FromBody] ParseByJobLinkDto parseByJobLinkDto) { if (parseByJobLinkDto.IgnoreAlreadySended) { await RemoveAlreadySentedJob(parseByJobLinkDto); } var account = await Context.AccountsPowerToFly.FirstAsync(x => x.Email == parseByJobLinkDto.AccountEmail); if (account == null) { return(new BadRequestObjectResult(new string("Account not found"))); } var site = await Context.Sites.FirstAsync(x => x.Name == SiteName); if (site == null) { return(new BadRequestObjectResult(new string("Site not found"))); } var botSignals = new BotSignalPowerToFly { Account = account, BotTypeSignal = BotTypeSignal.SendCoverLetterToJobsByLinks, IgnoreAlreadySended = parseByJobLinkDto.IgnoreAlreadySended, JobLinks = parseByJobLinkDto.JobLinks.Trim(), CoverrLetter = parseByJobLinkDto.CoverLetter, Status = BotSignalStatus.Waiting, MaxPageCount = Convert.ToInt32(parseByJobLinkDto.MaxPageCount), UpdateAt = DateTime.Now }; Context.BotSignalsPowerToFly.Add(botSignals); await Context.SaveChangesAsync(); return(new OkObjectResult(new { Message = "Bot signal created" })); }