Beispiel #1
0
        public void SetUp()
        {
            var mockData = new Mock <IWatchCatalog>();

            mockData.Setup(data => data.Catalog).Returns(this.Catalog);
            repository = new WatchRepository(mockData.Object);
        }
Beispiel #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);
        }
Beispiel #3
0
 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;
 }
Beispiel #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
            });
        }
Beispiel #5
0
 public void TearDown()
 {
     repository = null;
 }
Beispiel #6
0
 public void Delete(long id)
 {
     WatchRepository.Delete(id);
 }
Beispiel #7
0
 public WatchesController()
 {
     _watchRepository = new WatchRepository();
 }