Beispiel #1
0
        private async Task <bool> UpdateCategoryIfAlreadyExistsInOtherAffiliateProgram(
            IList <Category> existingCategorys,
            IList <AffiliateCategoryMatch> existingMatches,
            AffiliateCategory affiliateCategory)
        {
            if (existingCategorys == null || !existingCategorys.Any())
            {
                return(false);
            }
            if (existingMatches == null || !existingMatches.Any())
            {
                return(false);
            }

            var categoryToUpdate = existingCategorys.FirstOrDefault(category => category.IsMatchableName(affiliateCategory.Name));

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

            var newMatch = AffiliateCategoryMatch.Create(categoryToUpdate, affiliateCategory);
            await _matchesRepository.SaveAsync(newMatch);

            UpdateCategoryProperties(categoryToUpdate, affiliateCategory, existingMatches);
            await _categoryRepository.SaveAsync(categoryToUpdate);

            return(true);
        }
Beispiel #2
0
        private async Task CreateCategoryAndMatch(AffiliateCategory affiliateCategory)
        {
            var categoryToCreate = Category.Create();

            UpdateCategoryProperties(categoryToCreate, affiliateCategory);
            await _categoryRepository.SaveAsync(categoryToCreate);

            var newMatch = AffiliateCategoryMatch.Create(categoryToCreate, affiliateCategory);
            await _matchesRepository.SaveAsync(newMatch);
        }
Beispiel #3
0
 public void Update(AffiliateCategoryMatch categoryMatch)
 {
     if (categoryMatch == null)
     {
         throw new ArgumentNullException(nameof(categoryMatch));
     }
     if (Matched(categoryMatch))
     {
         CouponsCount = categoryMatch.CouponsCount;
     }
 }
Beispiel #4
0
 public bool Matched(AffiliateCategoryMatch affiliateCategory)
 {
     return(affiliateCategory != null && affiliateCategory.AffiliateCategoryId == AffiliateCategoryId && affiliateCategory.AffiliateProgram == AffiliateProgram);
 }