Пример #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);
        }
Пример #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);
        }
Пример #3
0
 public void Update(AffiliateCategoryMatch categoryMatch)
 {
     if (categoryMatch == null)
     {
         throw new ArgumentNullException(nameof(categoryMatch));
     }
     if (Matched(categoryMatch))
     {
         CouponsCount = categoryMatch.CouponsCount;
     }
 }
Пример #4
0
 public bool Matched(AffiliateCategoryMatch affiliateCategory)
 {
     return(affiliateCategory != null && affiliateCategory.AffiliateCategoryId == AffiliateCategoryId && affiliateCategory.AffiliateProgram == AffiliateProgram);
 }