Beispiel #1
0
 public UnitOfWork(ApplicationDbContext context)
 {
     Context = context;
     Drinks  = new DrinksRepository(context);
     Options = new OptionsRepository(context);
     Orders  = new OrdersRepository(context);
 }
        public void GivenQuestionIdAndOptionId_WhenItIsValid_ThenReturnCorrespondingMonitorId2()
        {
            OptionsRepository m = new OptionsRepository();
            int Actual          = 10;
            int expected        = m.datafetch2(11, 3);

            Assert.AreEqual(Actual, expected);
        }
        public void GivenQuestionIdAndOptionId_WhenItIsNotValid_ThenShouldNotReturnCorrespondingMonitorId()
        {
            OptionsRepository m = new OptionsRepository();
            int Actual          = 1;
            int expected        = m.datafetch2(12, 5);

            Assert.AreNotEqual(Actual, expected);
        }
        public void GivenQuestionIdAndOptionId_WhenItIsNotValid_ThenShouldNotReturnNextQuestionId()
        {
            OptionsRepository m = new OptionsRepository();
            int Actual          = 3;
            int expected        = m.datafetch(12, 1);

            Assert.AreNotEqual(Actual, expected);
        }
        public void GivenQuestionIdAndOptionId_WhenItIsValid_ThenReturnCorrespondingNextQuestionId()
        {
            OptionsRepository m = new OptionsRepository();
            int Actual          = 13;
            int expected        = m.datafetch(12, 2);

            Assert.AreNotEqual(Actual, expected);
        }
        public void initialise()
        {
            _mockOptions = new Mock <DbSet <Options> >();

            var mockContext = new Mock <IApplicationDbContext>();

            mockContext.SetupGet(o => o.Options).Returns(_mockOptions.Object);

            _repository = new OptionsRepository(mockContext.Object);
        }
Beispiel #7
0
 public ViewSurveyController(IUnitOfWork unitOfWork, MultichoiceQuestionRepository mr, Survey_MultichoiceQuestionRepository smr, Survey_FreeTextQuestionRepository sfr, FreeTextQuestionRepository ftr, ChapterRepository cr, OptionsRepository or, MultichoiceQuestion_OptionsRepository mor, SurveyRepository sr)
 {
     _unitOfWork = unitOfWork;
     _mr         = mr;
     _smr        = smr;
     _sfr        = sfr;
     _ftr        = ftr;
     _cr         = cr;
     _or         = or;
     _mor        = mor;
     _sr         = sr;
 }
        public MainForm()
        {
            InitializeComponent();
            settings = SettingsProvider.Get();

            var mefLoader = MefLoader.Get();
            var container = mefLoader.GetCompositionContainerr("Mtf.Persistence");

            rolesRepository     = container.GetExportedValue <RolesRepository>();
            usersRepository     = container.GetExportedValue <UsersRepository>();
            userRolesRepository = container.GetExportedValue <UserRolesRepository>();
            optionsRepository   = container.GetExportedValue <OptionsRepository>();

            currentUser = usersRepository.GetOrCreate(Environment.UserName);
        }
Beispiel #9
0
 public UnitOfWork(WebStoreContext context)
 {
     this.context   = context;
     Products       = new ProductsRepository(context);
     Sliders        = new SlidersRepository(context);
     FooterMenus    = new FooterMenusRepository(context);
     HeadingMenus   = new HeadingMenusRepository(context);
     Polls          = new PollsRepository(context);
     Prices         = new PricesRepository(context);
     ProductVariant = new ProductVariantsRepository(context);
     Colors         = new ColorsRepository(context);
     Votes          = new VotesRepository(context);
     Options        = new OptionsRepository(context);
     Ratings        = new RatingsRepository(context);
     Ordered        = new OrderedRepository(context);
     Orders         = new OrdersRepository(context);
 }
        /// <summary>
        /// 添加自定义的Repository服务,完成dbcontext的注入,Repository的注入
        /// </summary>
        /// <param name="services"></param>
        /// <param name="action"></param>
        public static void AddRepositorys(this IServiceCollection services, Action <OptionsRepository> action, IConfigurationRoot config)
        {
            OptionsRepository options = new OptionsRepository();

            action.Invoke(options);

            var dbOptions   = new DbOptionsBuilder();
            var dictOptions = new Dictionary <string, Action <DbContextOptionsBuilder> >();

            //加载dbcontext所有的连接串和初始化所需的DbContextOptionsBuilder
            foreach (var item in options.DbContexts)
            {
                dictOptions.Add(item.Key, dbOptions.Build(config.GetConnectionString(item.Key), providerOptions => providerOptions.CommandTimeout(60), Enum.Parse <DBType>(item.Value)));
            }


            ServiceRepository srv = new ServiceRepository(services, options);

            srv.LoadDbContext(dictOptions);
            srv.LoadRepository();
        }
Beispiel #11
0
        public RealStateDetailDto GetRealStateDetail(int id)
        {
            var model = new RealStateDetailDto();

            var lang = LanguageHelper.GetCulture();

            var _realStateRepos        = new RealStatesRepository(_context, new LogsRepository(_context));
            var _geoDivisionsRepo      = new GeoDivisionsRepository(_context, new LogsRepository(_context));
            var _planRepos             = new PlansRepository(_context, new LogsRepository(_context));
            var _optionRepos           = new OptionsRepository(_context, new LogsRepository(_context));
            var _realStateGalleryRepos = new RealStateGalleriesRepository(_context, new LogsRepository(_context));
            var _commentRepos          = new RealStateCommentsRepository(_context, new LogsRepository(_context));

            var realState        = _realStateRepos.GetRealStateWithNavigations(id);
            var realStateCity    = _geoDivisionsRepo.Get(realState.GeoDivisionId);
            var realStateState   = _geoDivisionsRepo.Get(realStateCity.ParentId.Value);
            var realStateCountry = _geoDivisionsRepo.GetGeoDivisionParent(realStateState.ParentId.Value);

            //var planId = 0;

            if (realState.Plans != null)
            {
                //planId = realState.Plans.FirstOrDefault().Id;

                var plans = _planRepos.GetRealStatePlans(realState.Id);
                var plan  = plans.FirstOrDefault();

                //var options = _optionRepos.GetPlanOptions(planId);

                model.Description = lang == (int)Language.Farsi ? realState.Description : realState.EnglishDescription;
                model.Region      = lang == (int)Language.Farsi ? realState.Region : realState.EnglishRegion;
                model.Type        = realState.Type;
                //model.Options = options;
                model.City     = realStateCity.Title;
                model.Country  = realStateCountry.Title;
                model.Id       = realState.Id;
                model.Area     = plan.Area;
                model.Bathroom = plan.BathRooms;
                model.Bedroom  = plan.Rooms;

                var price  = CurrencyHelper.ExchangeAmount(plan.Price, _currentCurrency);
                var symbol = CurrencyHelper.GetCurrencyUnit();

                model.Price            = price;
                model.PriceSymbol      = symbol;
                model.Address          = _geoDivisionsRepo.GetFullLocation(lang, realState.GeoDivisionId);
                model.Title            = lang == (int)Language.Farsi ? realState.Title : realState.EnglishTitle;
                model.ShortDescription = lang == (int)Language.Farsi ? realState.ShortDescription : realState.EnglishShortDescription;
                model.Image            = realState.Image;
                model.VideoStr         = realState.VideoStr;
                model.Plans            = realState.Plans;
                model.Location         = realState.Location;
                var vm = new List <PlanWithOptionDto>();

                foreach (var item in realState.Plans)
                {
                    var OPT = _optionRepos.GetPlanOptions(item.Id);
                    vm.Add(new PlanWithOptionDto()
                    {
                        Plan    = item,
                        Options = OPT
                    });
                }

                model.PlanWithOptions = vm;
            }

            model.RealStateGalleriesList = _realStateGalleryRepos.GetRealStateGalleries(id);

            var comments = _commentRepos.GetRealStateComments(id);

            model.RealStateCommentList.AddRange(comments);

            return(model);
        }
Beispiel #12
0
 public PlansController(PlansRepository repo,
                        OptionsRepository optionsRepo)
 {
     _repo        = repo;
     _optionsRepo = optionsRepo;
 }
Beispiel #13
0
 public OptionsController(OptionsRepository repo)
 {
     _repo = repo;
 }
Beispiel #14
0
 public OptionsService(OptionsRepository repo)
 {
     _repo = repo;
 }
Beispiel #15
0
 public ServiceRepository(IServiceCollection _services, OptionsRepository _options)
 {
     options  = _options;
     services = _services;
 }