예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public void Update(AffiliateStoreMatch storeMatch)
 {
     if (storeMatch == null)
     {
         throw new ArgumentNullException(nameof(storeMatch));
     }
     if (Matched(storeMatch))
     {
         CouponsCount = storeMatch.CouponsCount;
     }
 }
예제 #4
0
 public bool Matched(AffiliateStoreMatch affiliateStore)
 {
     return(affiliateStore != null && affiliateStore.AffiliateStoreId == AffiliateStoreId && affiliateStore.AffiliateProgram == AffiliateProgram);
 }