Exemple #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);
        }
Exemple #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);
        }