public Release(DAO.Release release) { Media = new Media(release.Media.MediaName); ReleaseNumber = release.ReleaseNumber; SubReleaseNumber = release.SubReleaseNumber; Url = release.Url; Notified = release.Notified; }
public bool IsNewerThan(DAO.Release release) { if (ReleaseNumber > release.ReleaseNumber) { return(true); } if (ReleaseNumber == release.ReleaseNumber) { return(SubReleaseNumber > release.SubReleaseNumber); } return(false); }
public async Task <Result> AddRelease(Release release) { if (await IsNewNewest(release)) { var releaseDao = new DAO.Release(release); var mediaResult = await _mediaDataStore.GetMedia(release.Media.MediaName); if (mediaResult.IsSuccess) { releaseDao.Media = mediaResult.Value; } _logger.LogInformation("Release with releaseNumber {releaseNumber}.{subReleaseNumber} is the newest for {mediaName} so it will be added", release.ReleaseNumber.ToString(), release.SubReleaseNumber.ToString(), release.Media.MediaName); return(await _releaseDataStore.AddRelease(releaseDao)); } _logger.LogInformation("Release with releaseNumber {releaseNumber} is not newer for {mediaName} so it will be discarded", release.ReleaseNumber.ToString(), release.Media.MediaName); return(Result.Failure($"Release with releaseNumber {release.ReleaseNumber.ToString()} is not newer for {release.Media.MediaName}")); }