public UnitOfWork(
            WordPressDbContext context,
            //IOptions<AppSettings> appSettings,
            ITermRepository termRepository,
            MetadataRepository metadataRepository,
            IMetadataService metadataService,
            OptionRepository optionRepository,
            AttachmentRepository attachmentRepository,
            ILoggerFactory loggerFactory
            //IOptions<ClientSettings> clientSettings,
            //RazorViewRenderer razorView
            )
        {
            _context = context;
            _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;

            //AppSettings = appSettings.Value;
            Posts = new PostRepository(_context);
            //TermService = new TermService(termRepository, memoryCache);
            MetadataService = metadataService;
            TermTaxonomies  = new TermTaxonomyRepository(_context);
            Options         = new OptionRepository(_context);
            Attachments     = new AttachmentRepository(_context);
            //RazorView = razorView;
            // this must be last one so the all services are working in this service
        }
Exemple #2
0
        public void OptionRepositoryTests_RetrieveOptions_ShouldRetrieve()
        {
            #region Assemble

            DbHelpers.ClearDatabase();
            OptionRepository  optionRepository  = new OptionRepository(DbHelpers.GetContextFactory());
            ConnectionManager connectionManager = new ConnectionManager(@"(local)\SQLExpress", "Odin");
            connectionManager.SetUseTrustedConnection(true);
            LogServiceFactory  logServiceFactory  = new LogServiceFactory("Odin");
            OdinContextFactory OdinContextFactory = new OdinContextFactory(connectionManager, logServiceFactory);

            #endregion // Assemble

            #region Act

            optionRepository.InsertOption("1", "Option1", "");
            optionRepository.InsertOption("2", "Option2", "");
            optionRepository.InsertOption("2", "Option22", "");
            optionRepository.InsertOption("3", "Option3", "");
            List <string> options = optionRepository.RetrieveOptions("2", "");

            #endregion // Act

            #region Assert

            Assert.AreEqual(2, options.Count);
            Assert.AreEqual("Option2", options[0]);
            Assert.AreEqual("Option22", options[1]);

            #endregion // Assert
        }
        public ImportDataService()
        {
            _exportDataService = new ExportDataService();

            _crmRepository                     = new CRMRepository();
            _eventRepository                   = new EventRepository();
            _configurationRespository          = new ConfigurationRepository();
            _hostedControlRepository           = new HostedControlRepository();
            _entityTypeRepository              = new EntityTypeRepository();
            _scriptletRepository               = new ScriptletRepository();
            _importResults                     = new List <ImportResult>();
            _entitySearchRepository            = new EntitySearchRepository();
            _sessionLineRepository             = new SessionLineRepository();
            _optionRepository                  = new OptionRepository();
            _actionRepository                  = new ActionRepository();
            _actionCallrepository              = new ActionCallRepository();
            _subActionCallsRepository          = new SubActionCallsRepository();
            _eventActionCallRepository         = new EventActionCallRepository();
            _toolbarRepository                 = new ToolbarRepository();
            _toolbarButtonRepository           = new ToolbarButtonRepository();
            _toolbarButtonActionCallRepository = new ToolbarButtonActionCallRepository();
            _toolbarHostedControlRepository    = new ToolbarHostedControlRepository();
            _wnrRepository                     = new WNRRepository();
            _wnrActionCallrepository           = new WNRActionCallRepository();
            _agentScriptTaskRepository         = new AgentScriptTaskRepository();
            _taskActionCallRepository          = new TaskActionCallRepository();
            _taskAnswerRepository              = new TaskAnswerRepository();
            _agentScriptAnswerRepository       = new AgentScriptAnswerRepository();
            _answerActionCallRepository        = new AnswerActionCallrepository();
        }
        public async void GetOptionByProductIdAndOptionIdAsync_ShouldGetOption()
        {
            // Arrange
            //create in memory options
            var options = new DbContextOptionsBuilder <DataBaseContext>()
                          .UseInMemoryDatabase(databaseName: "GetOptionByProductIdAndOptionIdAsync_ShouldGetOption")
                          .Options;

            using (var context = new DataBaseContext(options))
            {
                await context.AddRangeAsync(optionsList);

                await context.SaveChangesAsync();

                Assert.Equal(2, await context.ProductOption.CountAsync());
            }

            // Act
            using (var context = new DataBaseContext(options))
            {
                var repo = new OptionRepository(context);

                var result = await repo.GetOptionByProductIdAndOptionIdAsync(firstOption.ProductId, firstOption.Id);

                Assert.Equal(firstOption.Id, result.Id);
            }
        }
Exemple #5
0
        public void Update_Option_Success()
        {
            var options = new DbContextOptionsBuilder <BitcoinShowDBContext>()
                          .UseInMemoryDatabase(System.Guid.NewGuid().ToString())
                          .Options;
            var context   = new BitcoinShowDBContext(options);
            var newOption = new Option {
                Text = "New option"
            };

            context.Options.Add(newOption);
            context.SaveChanges();

            OptionRepository repository = new OptionRepository(context);
            Option           expected   = new Option();

            expected.Id   = newOption.Id;
            expected.Text = "Update option";

            Option actual = new Option();

            actual.Id   = newOption.Id;
            actual.Text = "Update option";

            repository.Update(actual);

            Assert.Equal(expected, actual);
        }
Exemple #6
0
        public void Update_Option_With_Text_Greater_Than_Max_Size_Error()
        {
            var options = new DbContextOptionsBuilder <BitcoinShowDBContext>()
                          .UseInMemoryDatabase(System.Guid.NewGuid().ToString())
                          .Options;
            var context   = new BitcoinShowDBContext(options);
            var newOption = new Option {
                Text = "New option"
            };

            context.Options.Add(newOption);
            context.SaveChanges();

            OptionRepository repository = new OptionRepository(context);

            Option updatedOption = new Option();

            updatedOption.Id   = newOption.Id;
            updatedOption.Text = new String('B', 201);

            ArgumentOutOfRangeException ex = Assert.Throws <ArgumentOutOfRangeException>(() => repository.Update(updatedOption));

            Assert.NotNull(ex);
            Assert.Equal(nameof(updatedOption.Text), ex.ParamName);
        }
        public UnitOfWork(ApplicationDbContext context)
        {
            _context = context;

            Attempts       = new AttemptRepository(_context);
            Exams          = new ExamRepository(_context);
            Images         = new ImageRepository(_context);
            NoteParameters = new NoteParameterRepository(_context);
            Notifications  = new NotificationRepository(_context);
            Notes          = new NoteRepository(_context);
            Opinions       = new OpinionRepository(_context);
            Options        = new OptionRepository(_context);
            Passages       = new PassageRepository(_context);
            Questions      = new QuestionRepository(_context);
            Requirements   = new RequirementRepository(_context);
            Roles          = new RoleRepository(_context);
            RoleClaims     = new RoleClaimRepository(_context);
            Standards      = new StandardRepository(_context);
            Sittings       = new SittingRepository(_context);
            Topics         = new TopicRepository(_context);
            Users          = new UserRepository(_context);
            UserClaims     = new UserClaimRepository(_context);
            UserLogins     = new UserLoginRepository(_context);
            UserRoles      = new UserRoleRepository(_context);
            UserTokens     = new UserTokenRepository(_context);
        }
Exemple #8
0
        public static Vote Convert(VoteInput input)
        {
            var optionRepo = new OptionRepository();
            var surveyRepo = new SurveyRepository();

            return(new Vote(input.Date, surveyRepo.GetById(input.SurveyId), optionRepo.GetById(input.OptionId)));
        }
Exemple #9
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context        = context;
     Questions       = new QuestionRepository(_context);
     Options         = new OptionRepository(_context);
     Users           = new UserRepository(_context);
     ContactMessages = new ContactMessageRepository(_context);
 }
Exemple #10
0
        public void Get_Option_By_Id_Not_Found()
        {
            var options = new DbContextOptionsBuilder <BitcoinShowDBContext>()
                          .UseInMemoryDatabase(System.Guid.NewGuid().ToString())
                          .Options;
            var context = new BitcoinShowDBContext(options);

            OptionRepository repository = new OptionRepository(context);

            var option = repository.Get(100);

            Assert.Null(option);
        }
Exemple #11
0
        public ActionResult AddProperties()
        {
            PaysRepository mr = new PaysRepository(ConfigurationManager.ConnectionStrings["CnstrDev"].ConnectionString);
            //select comme for
            //ici je retraduit le mapper de maptoDBModel a la requeque que j'ai fait
            List <PaysModel> ListePays = mr.GetCountries().Select(item => MapToDBModel.PaysToPaysModel(item)).ToList();

            OptionRepository   or           = new OptionRepository(ConfigurationManager.ConnectionStrings["CnstrDev"].ConnectionString);
            List <OptionModel> ListeOptions = or.GetAll().Select(item => MapToDBModel.OptionToOptionModel(item)).ToList();


            return(View());
        }
Exemple #12
0
        /// <summary>
        /// Charge une liste d'options à partir d'options existantes d'une réservation.
        /// </summary>
        /// <param name="booking">réservation existante pour mémoire</param>
        /// <param name="dates">plage de date de la réservation</param>
        /// <returns></returns>
        public static async Task <OptionsViewModel> CreateAsync(Booking booking, DateRange dates)
        {
            OptionsViewModel newInstance      = new OptionsViewModel();
            List <Option>    availableOptions = await OptionRepository.GetAvailablesBetweenAsync(dates);

            _setAvailableOptionChoiceEntities(booking, dates, newInstance, availableOptions);

            foreach (OptionChoiceEntity optChoiceEntity in newInstance._availableOptionChoiceEntities)
            {
                optChoiceEntity.PropertyChanged += newInstance._optionChanged;
            }
            return(newInstance);
        }
Exemple #13
0
        public void Delete_Option_Not_Found_Error()
        {
            var options = new DbContextOptionsBuilder <BitcoinShowDBContext>()
                          .UseInMemoryDatabase(System.Guid.NewGuid().ToString())
                          .Options;
            var context = new BitcoinShowDBContext(options);

            OptionRepository repository = new OptionRepository(context);

            Exception ex = Assert.Throws <DbUpdateException>(() => repository.Delete(1));

            Assert.NotNull(ex);
            Assert.Equal("The current option does not exists.", ex.Message);
        }
Exemple #14
0
        public void Add_Option_Without_Text_Error()
        {
            var options = new DbContextOptionsBuilder <BitcoinShowDBContext>()
                          .UseInMemoryDatabase(System.Guid.NewGuid().ToString())
                          .Options;
            var context = new BitcoinShowDBContext(options);
            OptionRepository repository = new OptionRepository(context);

            Option option            = new Option();
            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => repository.Add(option));

            Assert.NotNull(ex);
            Assert.Equal(nameof(option.Text), ex.ParamName);
        }
Exemple #15
0
        protected IAdminOptionsService GetService(ApplicationDbContext dbContext)
        {
            var optionRepository   = new OptionRepository(dbContext);
            var adminDeleteService = new AdminCommonDeleteService(dbContext);
            var adminEditService   = new AdminCommonEditService(dbContext);
            var adminCreateService = new AdminCommonCreateService(dbContext);
            var service            = new AdminOptionsService(
                optionRepository,
                adminDeleteService,
                adminEditService,
                adminCreateService);

            return(service);
        }
Exemple #16
0
        public void Delete_Option_Success()
        {
            var options = new DbContextOptionsBuilder <BitcoinShowDBContext>()
                          .UseInMemoryDatabase(System.Guid.NewGuid().ToString())
                          .Options;
            var context = new BitcoinShowDBContext(options);

            Option deleteOption = new Option();

            deleteOption.Text = "delete";
            context.Options.Add(deleteOption);
            context.SaveChanges();

            OptionRepository repository = new OptionRepository(context);

            repository.Delete(deleteOption.Id);
        }
Exemple #17
0
        public void Add_Option_With_Text_Greater_Than_Max_Size_Error()
        {
            var options = new DbContextOptionsBuilder <BitcoinShowDBContext>()
                          .UseInMemoryDatabase(System.Guid.NewGuid().ToString())
                          .Options;
            var context = new BitcoinShowDBContext(options);
            OptionRepository repository = new OptionRepository(context);

            Option option = new Option();

            option.Text = new String('A', 201);
            ArgumentOutOfRangeException ex = Assert.Throws <ArgumentOutOfRangeException>(() => repository.Add(option));

            Assert.NotNull(ex);
            Assert.Equal(nameof(option.Text), ex.ParamName);
            Assert.Equal(0, context.Options.Count());
        }
Exemple #18
0
        public void Add_Option_Success()
        {
            string text     = "Add_Option_Success";
            var    options2 = new DbContextOptionsBuilder <BitcoinShowDBContext>()
                              .UseInMemoryDatabase("asd")
                              .Options;
            var context2 = new BitcoinShowDBContext(options2);
            OptionRepository repository = new OptionRepository(context2);

            Option actual = new Option();

            actual.Text = text;

            repository.Add(actual);
            Assert.NotNull(actual);
            Assert.True(0 < actual.Id);
            Assert.Equal(text, actual.Text);
            Assert.Equal(1, context2.Options.Count());
        }
Exemple #19
0
        public void Get_Option_By_Id_Success()
        {
            var options = new DbContextOptionsBuilder <BitcoinShowDBContext>()
                          .UseInMemoryDatabase(System.Guid.NewGuid().ToString())
                          .Options;
            var context  = new BitcoinShowDBContext(options);
            var expected = new Option {
                Text = "New option"
            };

            context.Options.Add(expected);
            context.SaveChanges();
            OptionRepository repository = new OptionRepository(context);

            var actual = repository.Get(expected.Id);

            Assert.NotNull(actual);
            Assert.Equal(expected, actual);
        }
Exemple #20
0
        public static void WireUp()
        {
            ErrorLog.CreateFolder();
            try
            {
                ConnectionManager connectionManager = new ConnectionManager(Odin.Properties.Settings.Default.DbServerName, Odin.Properties.Settings.Default.DbName);
                // ConnectionManager connectionManager = new ConnectionManager(@"(local)\SQLExpress", "Odin");
                // connectionManager.SetUseTrustedConnection(true);
                connectionManager.SetUseTrustedConnection(false);
                connectionManager.SetPassword(Odin.Properties.Settings.Default.DbPassword);
                LogServiceFactory logServiceFactory = new LogServiceFactory("Odin");
                OdinContextFactory = new OdinContextFactory(connectionManager, logServiceFactory);

                OdinContext context = OdinContextFactory.CreateContext();
                if (!context.Database.Exists())
                {
                    DbSettingsView window = new DbSettingsView()
                    {
                        DataContext = new DbSettingsViewModel()
                    };
                    window.ShowDialog();
                    OdinContextFactory.CreateContext();
                }

                WorkbookReader     = new WorkbookReader();
                ItemRepository     = new ItemRepository(OdinContextFactory);
                OptionRepository   = new OptionRepository(OdinContextFactory);
                RequestRepository  = new RequestRepository(OdinContextFactory);
                TemplateRepository = new TemplateRepository(OdinContextFactory);
                ItemService        = new ItemService(WorkbookReader, ItemRepository, TemplateRepository);
                OptionService      = new OptionService(OptionRepository, RequestRepository);
                ExcelService       = new ExcelService(false, ItemService, OptionService, TemplateRepository, RequestRepository);
                EmailService       = new EmailService(OptionService);
            }
            catch (Exception e)
            {
                // MessageBox.Show(e.ToString());
                ErrorLog.LogError("Odin encountered an error with the database.", e.ToString());
                Environment.Exit(1);
            }
        }
 public CatalogService(RequestContext c,
                       CategoryRepository categories,
                       CategoryProductAssociationRepository crosses,
                       ProductRepository products,
                       ProductRelationshipRepository relationships,
                       ProductImageRepository productImages,
                       ProductReviewRepository productReviews,
                       VariantRepository productVariants,
                       OptionRepository productOptions,
                       ProductOptionAssociationRepository productsXOptions,
                       ProductFileRepository productFiles,
                       ProductVolumeDiscountRepository volumeDiscounts,
                       ProductPropertyValueRepository propertyValues,
                       ProductInventoryRepository inventory,
                       ProductTypeRepository types,
                       ProductTypePropertyAssociationRepository typesXProperties,
                       ProductPropertyRepository properties,
                       WishListItemRepository wishItems)
 {
     context = c;
     Categories = categories;
     CategoriesXProducts = crosses;
     ProductRelationships = relationships;
     this.Products = products;
     this.ProductImages = productImages;
     this.ProductReviews = productReviews;
     this.ProductVariants = productVariants;
     this.ProductOptions = productOptions;
     this.ProductsXOptions = productsXOptions;
     this.ProductFiles = productFiles;
     this.VolumeDiscounts = volumeDiscounts;
     this.ProductPropertyValues = propertyValues;
     this.ProductInventories = inventory;
     this.ProductTypes = types;
     this.ProductTypesXProperties = typesXProperties;
     this.ProductProperties = properties;
     this.WishListItems = wishItems;
 }
        public async void UpdateOptionAsync_ShouldUpdateOption()
        {
            // Arrange
            //create in memory options
            var options = new DbContextOptionsBuilder <DataBaseContext>()
                          .UseInMemoryDatabase(databaseName: "UpdateOptionAsync_ShouldUpdateOption")
                          .Options;

            using (var context = new DataBaseContext(options))
            {
                await context.AddRangeAsync(optionsList);

                await context.SaveChangesAsync();

                Assert.Equal(2, await context.ProductOption.CountAsync());
            }

            firstOption.Name        = "updated name";
            firstOption.Description = "updated des";

            // Act
            using (var context = new DataBaseContext(options))
            {
                var repo = new OptionRepository(context);

                var result = await repo.UpdateOptionAsync(firstOption);

                Assert.Equal(firstOption.Id, result.Id);
            }

            using (var context = new DataBaseContext(options))
            {
                var updatedoption = await context.ProductOption.FirstAsync(o => o.Id == firstOption.Id);

                Assert.Equal(firstOption.Name, updatedoption.Name);
                Assert.Equal(firstOption.Description, updatedoption.Description);
            }
        }
        public async void CreatOptionAsync_ShouldAdd()
        {
            // Arrange
            //create in memory options
            var options = new DbContextOptionsBuilder <DataBaseContext>()
                          .UseInMemoryDatabase(databaseName: "CreatOptionAsync_ShouldAdd")
                          .Options;

            // Act
            using (var context = new DataBaseContext(options))
            {
                var repository = new OptionRepository(context);

                var result = await repository.CreatOptionAsync(firstOption);

                // Assert
                Assert.Equal(firstOption, result);
            }

            using (var context = new DataBaseContext(options))
            {
                Assert.Equal(1, await context.ProductOption.CountAsync());
            }
        }
        public async void IsOptionExistedById_ShouldReturnBool()
        {
            // Arrange
            //create in memory options
            var options = new DbContextOptionsBuilder <DataBaseContext>()
                          .UseInMemoryDatabase(databaseName: "IsOptionExistedById_ShouldReturnBool")
                          .Options;

            using (var context = new DataBaseContext(options))
            {
                await context.AddRangeAsync(optionsList);

                await context.SaveChangesAsync();

                Assert.Equal(2, await context.ProductOption.CountAsync());
            }

            // Act
            using (var context = new DataBaseContext(options))
            {
                var repo = new OptionRepository(context);

                var result = await repo.IsOptionExistedById(firstOption.Id);

                Assert.Equal(true, result);
            }

            using (var context = new DataBaseContext(options))
            {
                var repo = new OptionRepository(context);

                var result = await repo.IsOptionExistedById(Guid.NewGuid());

                Assert.Equal(false, result);
            }
        }
Exemple #25
0
 /// <summary>
 ///    Remove a permission / role pair into the DB
 /// </summary>
 public void RemoveRolePermission(string permission, string role)
 {
     OptionRepository.RemoveRolePermission(permission, role);
 }
Exemple #26
0
 public static void LoadGlobalValues()
 {
     OptionRepository.RetrieveGloablOptionData();
     ItemRepository.RetrieveGlobalData();
 }
Exemple #27
0
 public HouseController(HouseRepository houseRepository, OptionRepository optionRepository, CategoryRepository categoryRepository)
 {
     _houseRepository    = houseRepository;
     _optionRepository   = optionRepository;
     _categoryRepository = categoryRepository;
 }
Exemple #28
0
 /// <summary>
 ///     Remove a user role
 /// </summary>
 /// <param name="userName"></param>
 /// <param name="role"></param>
 public void RemoveUserRole(string userName, string role)
 {
     OptionRepository.RemoveUserRole(userName, role);
 }
Exemple #29
0
 /// <summary>
 ///     Removes a row from ODIN_OPTIONS_TABLE
 /// </summary>
 /// <param name="optionId"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public void RemoveOption(string optionId, string value, string username)
 {
     OptionRepository.RemoveOption(optionId, value, username);
 }
Exemple #30
0
 /// <summary>
 ///     Insert a permission / role pair into the DB
 /// </summary>
 public void InsertRolePermission(string permission, string role)
 {
     OptionRepository.InsertRolePermission(permission, role);
 }
Exemple #31
0
 /// <summary>
 ///     Add a user / role pair to the db
 /// </summary>
 /// <param name="userName">Name of the user</param>
 /// <param name="role">Role to be granted to user</param>
 public void InsertUserRole(string userName, string role)
 {
     OptionRepository.InsertUserRole(userName, role);
 }