Exemplo n.º 1
0
        public UnitOfWork(ApplicationDbContext context)
        {
            _context      = context;
            EventCategory = new EventCategoryRepository(context);

            Evaluation = new EvaluationRepository(context);

            UserInterestCateogry  = new UserInterestCateogryRepository(context);
            UserParticipantsEvent = new UserParticipantsEventRepository(context);
            Event = new EventRepository(context);
        }
Exemplo n.º 2
0
        public bool canCreate(Event eventt)
        {
            EventCategoryRepository _eventCategoryRepository = new EventCategoryRepository();
            PlanningRepository      _planningRepository      = new PlanningRepository();
            EventRepository         _eventRepository         = new EventRepository();

            // interdiction de créer un évenement avec une catégorie qui n'existe pas
            if (_eventCategoryRepository.Get(eventt.IdEventCategory) == null)
            {
                return(false);
            }

            // interdiction de crééer un évenement dans un planning qui n'existe pas
            if (_planningRepository.Get(eventt.IdPlanning) == null)
            {
                return(false);
            }

            return(true);
        }
        public EventCategoryRepositoryTest()
        {
            var config = new ContentfulConfig("test")
                         .Add("DELIVERY_URL", "https://fake.url")
                         .Add("TEST_SPACE", "SPACE")
                         .Add("TEST_ACCESS_KEY", "KEY")
                         .Add("TEST_MANAGEMENT_KEY", "KEY")
                         .Build();

            _httpClient = new Mock <IHttpClient>();

            var contentfulClientManager = new Mock <IContentfulClientManager>();

            _contentfulClient = new Mock <IContentfulClient>();
            _contentfulEventCategoryFactory = new Mock <IContentfulFactory <ContentfulEventCategory, EventCategory> >();
            contentfulClientManager.Setup(o => o.GetClient(config)).Returns(_contentfulClient.Object);
            _cacheWrapper  = new Mock <ICache>();
            _configuration = new Mock <IConfiguration>();
            _configuration.Setup(_ => _["redisExpiryTimes:Events"]).Returns("60");
            _repository = new EventCategoryRepository(config, _contentfulEventCategoryFactory.Object, contentfulClientManager.Object, _cacheWrapper.Object, _configuration.Object);
        }