protected bool createRatingMarkers(IEnumerable <EmailForExtendedDto> emails) { try { SiteDal siteDal = new SiteDal(_configuration, _logger); RatingMarkerDal ratingMarkerDal = new RatingMarkerDal(_configuration, _logger); int added = 0; int updated = 0; foreach (EmailForExtendedDto emailForExtendedDto in emails) { int siteId = siteDal.GetSiteIdByExternalIdentifier(emailForExtendedDto.Folder).GetAwaiter().GetResult(); if (siteId > -1) { int ratingMarkerId = ratingMarkerDal.Put(RatingMarkerHelper.EmailForExtendedToRatingMarker(emailForExtendedDto, siteId)).GetAwaiter().GetResult(); if (ratingMarkerId < 0) { _logger.Error($"An error occured while saving rating marker to the database"); continue; } added++; if (_emailAlertsDal.Post(emailForExtendedDto.UniqueIdentifier, ratingMarkerId).GetAwaiter().GetResult() != CRUDEnums.ActionResult.Success) { _logger.Error($"An error occured while updating Email Alerts in the database"); continue; } updated++; } else { _logger.Information($"Error linking Highlight Folder - {emailForExtendedDto.Folder}"); } } _logger.Information($"RatingMarkers added to the database {added}"); _logger.Information($"EmailAlerts updated in the database {updated}"); if (added != emails.Count()) { _logger.Warning($"RatingMarkers not added to the database {(emails.Count() - added)}"); } } catch (Exception ex) { _logger.Error("Error Saving RatingMarkers", ex); return(false); } return(true); }