コード例 #1
0
        public void SetUp()
        {
            var mockData = new Mock <IWatchCatalog>();

            mockData.Setup(data => data.Catalog).Returns(this.Catalog);
            repository = new WatchRepository(mockData.Object);
        }
コード例 #2
0
        public void Save(Watch entity)
        {
            if (WatchRepository.Any(w => w.PersonId == entity.PersonId && w.WebResourceId == entity.WebResourceId))
            {
                throw this.ValidationException(e => e.PersonId, $"Watch already set for this {typeof(Person).Name.SplitUpperCaseBySpace()} and {typeof(WebResource).Name.SplitUpperCaseBySpace()}.");
            }

            WatchRepository.Save(entity);
        }
コード例 #3
0
ファイル: WatchBusiness.cs プロジェクト: ahmadshafiei/Watch
 public WatchBusiness(BrandRepository brandRepository, WatchRepository watchRepository, WatchBookmarkRepository bookmarkRepository, StoreRepository storeRepository, SellerRepository sellerRepository, SuggestPriceRepository suggestPriceRepository, UserRepository userRepository, UnitOfWork unitOfWork)
 {
     this.watchRepository        = watchRepository;
     this.bookmarkRepository     = bookmarkRepository;
     this.brandRepository        = brandRepository;
     this.unitOfWork             = unitOfWork;
     this.storeRepository        = storeRepository;
     this.sellerRepository       = sellerRepository;
     this.suggestPriceRepository = suggestPriceRepository;
     this.userRepository         = userRepository;
 }
コード例 #4
0
        public void Set(long webResourceId, string accountId)
        {
            if (!WebResourceRepository.Any(r => r.Id == webResourceId))
            {
                throw new ArgumentException("Not exist.", nameof(webResourceId));
            }

            var validAccountId = WebResourceAccountIdValidator.GetValidAccountId(webResourceId, accountId);

            if (validAccountId == null)
            {
                throw new ArgumentException("Invalid.", nameof(accountId));
            }

            var personId = MetaAccountRepository.FirstOrDefault(
                a => a.AccountId == validAccountId && a.WebResourceId == webResourceId,
                a => a.PersonId);

            if (personId == 0)
            {
                var person = new Person();
                PersonService.Save(person);
                UnitOfWork.Commit();

                personId = person.Id;
                var account = new MetaAccount
                {
                    PersonId      = personId,
                    Type          = MetaType.Created,
                    AccountId     = validAccountId,
                    WebResourceId = webResourceId
                };

                MetaAccountService.Save(account);
                UnitOfWork.Commit();
            }

            if (WatchRepository.Any(w => w.PersonId == personId && w.WebResourceId == webResourceId))
            {
                return;
            }

            Save(new Watch
            {
                PersonId      = personId,
                WebResourceId = webResourceId
            });
        }
コード例 #5
0
 public void TearDown()
 {
     repository = null;
 }
コード例 #6
0
 public void Delete(long id)
 {
     WatchRepository.Delete(id);
 }
コード例 #7
0
 public WatchesController()
 {
     _watchRepository = new WatchRepository();
 }