public void should_create_repository()
 {
     var mockFactory = new FakeMongoDatabaseFactory();
     var sut = new RepositoryFactory(mockFactory);
     var result = sut.Create<User>(new RepositoryOptions("lorem", "ipsum", "users"));
     result.Should().NotBeNull();
     result.CollectionName.ShouldBeEquivalentTo("users");
 }
        public void ShouldCreateSimpleRepositoryWithContextNoLog()
        {
            //Arrange
            var testDomain = new TestDomain();
            IRepositoryFactory factory = new RepositoryFactory(testDomain.ConnectionString, testDomain.Mappings, testDomain.Context);

            //Act
            IRepository repo = factory.Create();

            // assert
            repo.Should().NotBeNull();
        }
        public void Should_Get_Mappings_Specific_To_The_Type_Requested()
        {
            //Arrange
            Func<Type, IMappingConfiguration> mappingsDelegate = x =>
                                                                     {
                                                                         if (x == typeof (Foo)) return fooMapping;
                                                                         return null;
                                                                     };
            var target = new RepositoryFactory(Settings.Default.Connection, mappingsDelegate);

            //Act
            var repository = target.Create<Foo>();
            try
            {
                repository.Context.AsQueryable<Foo>().ToList();
            }
            catch (Exception)
            {
                //Suppress the error from the context. This allows us to test the mappings peice without having to actually map.
            }
            //Assert
            fooMapping.VerifyAllExpectations();
        }
        //Function to update ClientID
        protected virtual OperationResult _UpdateClientID(Int64 idRefreshToken, string clientID)
        {
            //Create repository based on its Key name : 'Keywords.UpdateRefreshToken'.
            //The repository factory will create the repository object based on its key.
            IUpdateRefreshTokenRepository repository = (IUpdateRefreshTokenRepository)RepositoryFactory.Create(Keywords.UpdateRefreshToken);

            try
            {
                //Execute UpdateClientID
                repository.UpdateClientID(idRefreshToken, clientID);
                return(new OperationResult(true, null));
            }
            catch (Exception e)
            {
                //Return false if error along with its exception
                return(new OperationResult(false, e));
            }
        }
예제 #5
0
        public string Index()
        {
            if (isRuning == true)
            {
                return("正在运行中");
            }
            lock (lockObj)
            {
                isRuning = true;
                try
                {
                    using (var tran = DBTool.BeginTransaction())
                    {
                        var repositoryFactory = RepositoryFactory.Create <ProductSaleByDayEntity>();
                        var query             = QueryFactory.Create <ProductSaleByDayEntity>(m => m.CreateDate > DateTime.Now.Date);
                        query.DBModel.DBModel_ShuffledTempDate = new DateTime(2019, 09, 01);
                        if (repositoryFactory.GetList(query).Count > 10)
                        {
                            return("");
                        }
                        var importGroupId = Guid.NewGuid();
                        var random        = new Random();

                        var tempDate = new DateTime(2018, 1, 1);
                        while (tempDate <= new DateTime(2019, 12, 31))
                        {
                            if (tempDate.Day == 1)
                            {
                                query = QueryFactory.Create <ProductSaleByDayEntity>();
                                query.DBModel.DBModel_ShuffledTempDate = tempDate;
                                repositoryFactory.Delete(query);
                            }
                            foreach (var p in dicProduct)
                            {
                                var temp = new ProductSaleByDayEntity();

                                temp.SysNo           = Guid.NewGuid();
                                temp.DataSource      = lstDataSource[random.Next(lstDataSource.Count)];
                                temp.ShopName        = "测试店铺";
                                temp.ProductID       = p.Key;
                                temp.OutProductID    = p.Value;
                                temp.ProductName     = p.Value;
                                temp.Sales           = random.Next(100000);
                                temp.StatisticalDate = tempDate;
                                temp.UpdateDate      = temp.CreateDate = DateTime.Now;
                                temp.UpdateUserID    = temp.CreateUserID = Guid.NewGuid();
                                temp.ImportGroupId   = importGroupId;
                                repositoryFactory.Add(temp);
                            }
                            tempDate = tempDate.AddDays(1);
                        }
                        tran.Complete();
                    }
                }
                finally
                {
                    isRuning = false;
                }
                return("初始化成功");
            }
        }
예제 #6
0
        //Function to update AuthenticationCodeString
        protected virtual OperationResult _UpdateAuthenticationCodeString(Int64 idAuthenticationCode, string authenticationCodeString)
        {
            //Create repository based on its Key name : 'Keywords.UpdateAuthenticationCode'.
            //The repository factory will create the repository object based on its key.
            IUpdateAuthenticationCodeRepository repository = (IUpdateAuthenticationCodeRepository)RepositoryFactory.Create(Keywords.UpdateAuthenticationCode);

            try
            {
                //Execute UpdateAuthenticationCodeString
                repository.UpdateAuthenticationCodeString(idAuthenticationCode, authenticationCodeString);
                return(new OperationResult(true, null));
            }
            catch (Exception e)
            {
                //Return false if error along with its exception
                return(new OperationResult(false, e));
            }
        }
예제 #7
0
 public DepartmentsService()
     : this(RepositoryFactory.Create <Departments>())
 {
 }
예제 #8
0
        protected IEntityRepository CreateRepository(string type)
        {
            RepositoryFactory factory = new RepositoryFactory();

            return(factory.Create(type));
        }
예제 #9
0
 public DomainService()
     : this(RepositoryFactory.Create <Domain>())
 {
 }
예제 #10
0
        public string Index()
        {
            if (isRuning == true)
            {
                return("正在运行中");
            }
            lock (lockObj)
            {
                isRuning = true;
                try
                {
                    var shopRepository = RepositoryFactory.Create <ShopEntity>();
                    shopRepository.Delete(QueryFactory.Create <ShopEntity>());
                    for (int i = 0; i < 10; i++)
                    {
                        var shop = new ShopEntity
                        {
                            SysNo    = Guid.NewGuid(),
                            ShopCode = "00" + i,
                            ShopName = "测试店铺" + i,
                            ShopType = i % 3
                        };
                        shopRepository.Add(shop);
                    }
                    lstShop = shopRepository.GetList(QueryFactory.Create <ShopEntity>());
                    var importGroupId       = Guid.NewGuid();
                    var random              = new Random();
                    var repositoryFactory   = RepositoryFactory.Create <ProductSaleByDayEntity>();
                    var repositoryNSFactory = RepositoryFactory.Create <ProductSaleByDayNSEntity>();
                    repositoryNSFactory.Delete(QueryFactory.Create <ProductSaleByDayNSEntity>());
                    var tempDate = new DateTime(2018, 1, 1);
                    while (tempDate <= DateTime.Now.Date)
                    {
                        if (tempDate.Day == 1)
                        {
                            var query = QueryFactory.Create <ProductSaleByDayEntity>();
                            query.DBModel.DBModel_ShuffledTempDate = tempDate;
                            repositoryFactory.Delete(query);
                        }
                        foreach (var p in dicProduct)
                        {
                            var temp   = new ProductSaleByDayEntity();
                            var tempNS = new ProductSaleByDayNSEntity();
                            tempNS.SysNo      = temp.SysNo = Guid.NewGuid();
                            tempNS.DataSource = temp.DataSource = lstDataSource[random.Next(lstDataSource.Count)];
                            tempNS.ShopID     = temp.ShopID = lstShop[random.Next(lstShop.Count)].SysNo;

                            tempNS.ProductID       = temp.ProductID = p.Key;
                            tempNS.OutProductID    = temp.OutProductID = p.Value;
                            tempNS.ProductName     = temp.ProductName = p.Value;
                            tempNS.Sales           = temp.Sales = random.Next(100000);
                            tempNS.StatisticalDate = temp.StatisticalDate = tempDate;
                            tempNS.UpdateDate      = temp.UpdateDate = temp.CreateDate = DateTime.Now;
                            tempNS.UpdateUserID    = temp.UpdateUserID = temp.CreateUserID = Guid.NewGuid();
                            tempNS.ImportGroupId   = temp.ImportGroupId = importGroupId;
                            repositoryFactory.Add(temp);
                            repositoryNSFactory.Add(tempNS);
                        }
                        tempDate = tempDate.AddDays(1);
                    }
                }
                finally
                {
                    isRuning = false;
                }
                return("初始化成功");
            }
        }
예제 #11
0
 public UserSiteService()
     : this(RepositoryFactory.Create <UserSite>(), RepositoryFactory.Create <Site>())
 {
 }
예제 #12
0
        /// <summary>
        /// Finds all  Application Setting data with app Name containing specified keyword
        /// </summary>
        /// <param name="appName"> App Name</param>
        /// <returns>The result of the operation</returns>
        public OperationResult FindByAppName(string appName)
        {
            IFindApplicationSettingRepository repository = (IFindApplicationSettingRepository)RepositoryFactory.Create(Keywords.FindApplicationSetting);

            try
            {
                List <ApplicationSetting> res = repository.FindByAppName(appName);
                return(new OperationResult(true, res));
            }
            catch (Exception e)
            {
                return(new OperationResult(false, e));
            }
        }
        //Function to update ApplicationName
        protected virtual OperationResult _UpdateApplicationName(Int16 idApplication, string applicationName)
        {
            //Create repository based on its Key name : 'Keywords.UpdateApplicationItem'.
            //The repository factory will create the repository object based on its key.
            IUpdateApplicationItemRepository repository = (IUpdateApplicationItemRepository)RepositoryFactory.Create(Keywords.UpdateApplicationItem);

            try
            {
                //Execute UpdateApplicationName
                repository.UpdateApplicationName(idApplication, applicationName);
                return(new OperationResult(true, null));
            }
            catch (Exception e)
            {
                //Return false if error along with its exception
                return(new OperationResult(false, e));
            }
        }
예제 #14
0
 public ErrorInfoService()
     : this(RepositoryFactory.Create <ErrorInfo>())
 {
 }
        public EditEmployeeViewModel()
        {
            _employeeRepository = RepositoryFactory <Employee> .Create();

            _departmentRepository = RepositoryFactory <Department> .Create();
        }
        public void BeAbleToCreateASubstanceRepository()
        {
            var repos = RepositoryFactory.Create <Substance>();

            Assert.IsInstanceOfType(repos, typeof(SubstanceRepository));
        }
예제 #17
0
 public ProgramService()
     : this(RepositoryFactory.Create <Program>(), RepositoryFactory.Create <Privilege>())
 {
 }
예제 #18
0
 public InformationHistoryService()
     : this(RepositoryFactory.Create <InformationHistory>())
 {
 }
        //Function to delete SessionExpiredDate
        protected virtual OperationResult _DeleteBySessionExpiredDate(DateTime sessionExpiredDate)
        {
            //Create repository based on its Key name : 'Keywords.DeleteAuthenticationSession'.
            //The repository factory will create the repository object based on its key.
            IDeleteAuthenticationSessionRepository repository = (IDeleteAuthenticationSessionRepository)RepositoryFactory.Create(Keywords.DeleteAuthenticationSession);

            try
            {
                //Execute DeleteBySessionExpiredDate
                repository.DeleteBySessionExpiredDate(sessionExpiredDate);
                return(new OperationResult(true, null));
            }
            catch (Exception e)
            {
                return(new OperationResult(false, e));
            }
        }
        //Function to delete AuthenticationCodeString
        protected virtual OperationResult _DeleteByAuthenticationCodeString(string authenticationCodeString)
        {
            //Create repository based on its Key name : 'Keywords.DeleteAuthenticationCode'.
            //The repository factory will create the repository object based on its key.
            IDeleteAuthenticationCodeRepository repository = (IDeleteAuthenticationCodeRepository)RepositoryFactory.Create(Keywords.DeleteAuthenticationCode);

            try
            {
                //Execute DeleteByAuthenticationCodeString
                repository.DeleteByAuthenticationCodeString(authenticationCodeString);
                return(new OperationResult(true, null));
            }
            catch (Exception e)
            {
                return(new OperationResult(false, e));
            }
        }
        //Function to delete ApplicationGroupName
        protected virtual OperationResult _DeleteByApplicationGroupName(string applicationGroupName)
        {
            //Create repository based on its Key name : 'Keywords.DeleteApplicationGroup'.
            //The repository factory will create the repository object based on its key.
            IDeleteApplicationGroupRepository repository = (IDeleteApplicationGroupRepository)RepositoryFactory.Create(Keywords.DeleteApplicationGroup);

            try
            {
                //Execute DeleteByApplicationGroupName
                repository.DeleteByApplicationGroupName(applicationGroupName);
                return(new OperationResult(true, null));
            }
            catch (Exception e)
            {
                return(new OperationResult(false, e));
            }
        }
예제 #22
0
 public DvdController()
 {
     _repo = RepositoryFactory.Create();
 }
예제 #23
0
 public RoleMasterService() : this(RepositoryFactory.Create <RoleMaster>())
 {
 }
예제 #24
0
        public string Index()
        {
            if (isRuning == true)
            {
                return("正在运行中");
            }
            lock (lockObj)
            {
                isRuning = true;
                try
                {
                    var repositoryNSFactory = RepositoryFactory.Create <ProductSaleByDayNSEntity>();
                    using (var tran = DBTool.BeginTransaction())
                    {
                        if (repositoryNSFactory.GetList(m => m.CreateDate > DateTime.Now.Date).Count > 100)
                        {
                            tran.Complete();
                            return("");
                        }
                    }
                    var shopRepository = RepositoryFactory.Create <ShopEntity>();
                    shopRepository.Delete(QueryFactory.Create <ShopEntity>());

                    using (var tran = DBTool.BeginTransaction())
                    {
                        for (int i = 0; i < 10; i++)
                        {
                            var shop = new ShopEntity
                            {
                                SysNo    = Guid.NewGuid(),
                                ShopCode = "00" + i,
                                ShopName = "测试店铺" + i,
                                ShopType = i % 3,
                                IsDelete = false,
                            };
                            shopRepository.Add(shop);
                        }
                        lstShop = shopRepository.GetList(QueryFactory.Create <ShopEntity>());
                        tran.Complete();
                    }
                    var importGroupId = Guid.NewGuid();
                    var random        = new Random();

                    repositoryNSFactory.Delete(QueryFactory.Create <ProductSaleByDayNSEntity>());
                    var tempDate = new DateTime(2018, 1, 1);
                    while (tempDate <= DateTime.Now)
                    {
                        using (var tran = DBTool.BeginTransaction())
                        {
                            foreach (var p in dicProduct)
                            {
                                var tempNS = new ProductSaleByDayNSEntity();
                                tempNS.SysNo      = Guid.NewGuid();
                                tempNS.DataSource = lstDataSource[random.Next(lstDataSource.Count)];
                                var shop = lstShop[random.Next(lstShop.Count)];
                                tempNS.ShopID = shop.SysNo;

                                tempNS.ProductID       = p.Key;
                                tempNS.OutProductID    = p.Value;
                                tempNS.ProductName     = p.Value;
                                tempNS.Sales           = random.Next(100000);
                                tempNS.StatisticalDate = tempDate;
                                tempNS.CreateDate      = DateTime.Now;
                                tempNS.CreateUserID    = Guid.NewGuid();
                                tempNS.ImportGroupId   = importGroupId;

                                repositoryNSFactory.Add(tempNS);
                            }
                            tempDate = tempDate.AddDays(1);
                            tran.Complete();
                        }
                    }
                }
                finally
                {
                    isRuning = false;
                }
                return("初始化成功");
            }
        }
예제 #25
0
 private static IRepository <User> GetUserRepository()
 {
     return(RepositoryFactory.Create <User>());
 }
예제 #26
0
 private void btnTest_Click(object sender, EventArgs e)
 {
     RepositoryFactory.Create <StudentEFRepository>(ContextTypes.EntityFramework);
 }
예제 #27
0
 public GlobalResourcesService() : this(
         RepositoryFactory.Create <GlobalResources>(),
         IocObjectManager.GetInstance().Resolve <IHttpContextCacheManager>())
 {
 }
        //Function to update UserID
        protected virtual OperationResult _UpdateUserID(Int16 idGlobalApplicationSetting, string userID)
        {
            //Create repository based on its Key name : 'Keywords.UpdateGlobalApplicationSetting'.
            //The repository factory will create the repository object based on its key.
            IUpdateGlobalApplicationSettingRepository repository = (IUpdateGlobalApplicationSettingRepository)RepositoryFactory.Create(Keywords.UpdateGlobalApplicationSetting);

            try
            {
                //Execute UpdateUserID
                repository.UpdateUserID(idGlobalApplicationSetting, userID);
                return(new OperationResult(true, null));
            }
            catch (Exception e)
            {
                //Return false if error along with its exception
                return(new OperationResult(false, e));
            }
        }
        /// <summary>
        /// Finds all  Authentication Code data with authorization Session I D containing specified keyword
        /// </summary>
        /// <param name="authorizationSessionID"> Authorization Session I D</param>
        /// <returns>The result of the operation</returns>
        public OperationResult FindByAuthorizationSessionID(string authorizationSessionID)
        {
            IFindAuthenticationCodeRepository repository = (IFindAuthenticationCodeRepository)RepositoryFactory.Create(Keywords.FindAuthenticationCode);

            try
            {
                List <AuthenticationCode> res = repository.FindByAuthorizationSessionID(authorizationSessionID);
                return(new OperationResult(true, res));
            }
            catch (Exception e)
            {
                return(new OperationResult(false, e));
            }
        }
        /// <summary>
        /// Finds all  Authentication Code data with created Date1, created Date2 containing specified keyword
        /// </summary>
        /// <param name="createdDate1"> Created Date</param>
        /// <param name="createdDate2"> Created Date</param>
        /// <returns>The result of the operation</returns>
        public OperationResult FindByCreatedDateBetween(DateTime createdDate1, DateTime createdDate2)
        {
            IFindAuthenticationCodeRepository repository = (IFindAuthenticationCodeRepository)RepositoryFactory.Create(Keywords.FindAuthenticationCode);

            try
            {
                List <AuthenticationCode> res = repository.FindByCreatedDateBetween(createdDate1, createdDate2);
                return(new OperationResult(true, res));
            }
            catch (Exception e)
            {
                return(new OperationResult(false, e));
            }
        }
        /// <summary>
        /// Finds all  Authentication Source data with authentication Classname containing specified keyword
        /// </summary>
        /// <param name="authenticationClassname"> Authentication Classname</param>
        /// <returns>The result of the operation</returns>
        public OperationResult FindByAuthenticationClassname(string authenticationClassname)
        {
            IFindAuthenticationSourceRepository repository = (IFindAuthenticationSourceRepository)RepositoryFactory.Create(Keywords.FindAuthenticationSource);

            try
            {
                List <AuthenticationSource> res = repository.FindByAuthenticationClassname(authenticationClassname);
                return(new OperationResult(true, res));
            }
            catch (Exception e)
            {
                return(new OperationResult(false, e));
            }
        }