private async Task <bool> UpdateStoreIfAlreadyExistsInOtherAffiliateProgram( IList <Store> existingStores, IList <AffiliateStoreMatch> existingMatches, AffiliateStore affiliateStore) { if (existingStores == null || !existingStores.Any()) { return(false); } if (existingMatches == null || !existingMatches.Any()) { return(false); } var storeToUpdate = existingStores.FirstOrDefault(store => store.IsMatchableName(affiliateStore.Name)); if (storeToUpdate == null) { return(false); } var newMatch = AffiliateStoreMatch.Create(storeToUpdate, affiliateStore); await _matchesRepository.SaveAsync(newMatch); UpdateStoreProperties(storeToUpdate, affiliateStore, existingMatches); await _storeRepository.SaveAsync(storeToUpdate); return(true); }
private async Task CreateStoreAndMatch(AffiliateStore affiliateStore) { var storeToCreate = Store.Create(); UpdateStoreProperties(storeToCreate, affiliateStore); await _storeRepository.SaveAsync(storeToCreate); var newMatch = AffiliateStoreMatch.Create(storeToCreate, affiliateStore); await _matchesRepository.SaveAsync(newMatch); }
public void Update(AffiliateStoreMatch storeMatch) { if (storeMatch == null) { throw new ArgumentNullException(nameof(storeMatch)); } if (Matched(storeMatch)) { CouponsCount = storeMatch.CouponsCount; } }
public bool Matched(AffiliateStoreMatch affiliateStore) { return(affiliateStore != null && affiliateStore.AffiliateStoreId == AffiliateStoreId && affiliateStore.AffiliateProgram == AffiliateProgram); }