示例#1
0
        public static AffiliateStoreMatch Create(Store store, AffiliateStore affiliateStore)
        {
            var match = affiliateStore.GetAdvertiseId();

            match.AdvertiseStoreId = store.StoreId;
            return(match);
        }
示例#2
0
        private async Task <bool> UpdateStoreIfAlreadyExistsInTheSameAffiliateProgram(
            IList <Store> existingStores,
            IList <AffiliateStoreMatch> existingMatches,
            AffiliateStore affiliateStore)
        {
            if (existingStores == null || !existingStores.Any())
            {
                return(false);
            }
            if (existingMatches == null || !existingMatches.Any())
            {
                return(false);
            }

            var advertiseId   = affiliateStore.GetAdvertiseId();
            var previousMatch = existingMatches.FirstOrDefault(id => id.Matched(advertiseId));

            if (previousMatch == null)
            {
                return(false);
            }

            var foundStore = existingStores.FirstOrDefault(store => store.StoreId == previousMatch.AdvertiseStoreId);

            if (foundStore == null)
            {
                return(false);
            }

            // Update match
            previousMatch.Update(advertiseId);
            await _matchesRepository.SaveAsync(previousMatch);

            // Update store
            UpdateStoreProperties(foundStore, affiliateStore, existingMatches);
            await _storeRepository.SaveAsync(foundStore);

            return(true);
        }