Ejemplo n.º 1
0
        public void InsertThenUpdate_ShouldReflectChanges()
        {
            // Arrange
            var expectedValue = "*****@*****.**";
            var dummyString   = Guid.NewGuid().ToString().Replace("-", "");
            var dbModel       = new SubCategoryModel()
            {
                Description = dummyString,
            };

            // Act
            var newId = new SubCategoryRepository(AppState.ConnectionString)
                        .Insert(dbModel);
            var dbModel2 = new SubCategoryRepository(AppState.ConnectionString)
                           .Select(newId);

            dbModel2.Description = expectedValue;

            new SubCategoryRepository(AppState.ConnectionString)
            .Update(dbModel2);
            var actualValue = new SubCategoryRepository(AppState.ConnectionString)
                              .Select(newId)
                              .Description;

            // Assert
            Assert.AreEqual(expectedValue, actualValue);
        }
Ejemplo n.º 2
0
        public void InsertBulkThenSelectList_ShouldEqualTwo()
        {
            // Arrange
            var expectedValue = 2;
            var dummyString   = Guid.NewGuid().ToString().Replace("-", "");
            var listPoco      = new List <SubCategoryModel>()
            {
                new SubCategoryModel()
                {
                    Description = dummyString,
                },
                new SubCategoryModel()
                {
                    Description = dummyString,
                }
            };

            // Act
            new SubCategoryRepository(AppState.ConnectionString).InsertBulk(listPoco);
            var actualValue = new SubCategoryRepository(AppState.ConnectionString)
                              .SelectList()
                              .Where(x => x.Description.Equals(dummyString))
                              .ToList()
                              .Count;

            // Assert
            Assert.AreEqual(expectedValue, actualValue);
        }
Ejemplo n.º 3
0
        public SubCategoryBusiness(DatabaseFactory df = null, UnitOfWork uow = null)
        {
            DatabaseFactory dfactory = df == null ? new DatabaseFactory() : df;

            _unitOfWork            = uow == null ? new UnitOfWork(dfactory) : uow;
            _subcategoryRepository = new SubCategoryRepository(dfactory);
        }
 public ProdeuctModelManager()
 {
     _generalCategoryRepository = new GeneralCategoryRepository();
     _categoryRepository        = new CategoryRepository();
     _subCategoryRepository     = new SubCategoryRepository();
     _productModelRepository    = new ProductModelRepository();
 }
Ejemplo n.º 5
0
 public UnitOfWork(DataContext context)
 {
     _context      = context;
     Categories    = new CategoryRepository(context);
     SubCategories = new SubCategoryRepository(context);
     Items         = new ItemRepository(context);
 }
 public SubCategorysController(ILogger <SubCategorysController> logger,
                               SubCategoryRepository subCategoryRepository, IConfiguration configuration)
 {
     _logger = logger;
     _subCategoryRepository = subCategoryRepository;
     _configuration         = configuration;
 }
Ejemplo n.º 7
0
        public IActionResult Update(int id)
        {
            var list = new SubCategoryRepository().GetUISubCategories();

            ViewBag.SubCategorys = list;

            return(View("AddOrUpdate", repository.GetByColumName("Id", id).FirstOrDefault()));
        }
Ejemplo n.º 8
0
        public void SetUp()
        {
            _dbContextOptions = new DbContextOptionsBuilder <DueltankDbContext>()
                                .UseInMemoryDatabase("dueltank")
                                .Options;

            _sut = new SubCategoryRepository(new DueltankDbContext(_dbContextOptions));
        }
Ejemplo n.º 9
0
 public UnitOfWork(HierarichyContext context)
 {
     _context              = context;
     DepartmentRepository  = new DepartmentRepository(context);
     CategoryRepository    = new CategoryRepository(context);
     SubCategoryRepository = new SubCategoryRepository(context);
     LocationRepository    = new LocationRepository(context);
 }
Ejemplo n.º 10
0
 public UnitOfWork()
 {
     _dbContext  = new MyContext();
     User        = new UserRepository(_dbContext);
     Product     = new ProductRepository(_dbContext);
     Category    = new CategoryRepository(_dbContext);
     SubCategory = new SubCategoryRepository(_dbContext);
     WishList    = new WishListRepository(_dbContext);
 }
Ejemplo n.º 11
0
        public void TestSubCategoryConnection()
        {
            _subrepo = new SubCategoryRepository(new BzaleDatabaseContext());

            var category = _subrepo.GetSubCategoriesByMainID(30, 1, int.MaxValue);


            Assert.IsNotNull(category);
        }
 public TodoAppDbContext(DbContextOptions options) : base(options)
 {
     context               = this;
     CategoryRepository    = new CategoryRepository(context);
     SubCategoryRepository = new SubCategoryRepository(context);
     TodoRepository        = new TodoRepository(context);
     NoteRepository        = new NoteRepository(context);
     LinkRepository        = new LinkRepository(context);
     FileRepository        = new FileRepository(context);
 }
Ejemplo n.º 13
0
 public UnitOfWork(JooleContext context)
 {
     _context      = context;
     Users         = new UserRepository(_context);
     Categories    = new CategoryRepository(_context);
     SubCategories = new SubCategoryRepository(_context);
     Products      = new ProductRepository(_context);
     TechProps     = new TechPropRepository(_context);
     TypeProps     = new TypePropRepository(_context);
     Manufacturers = new ManufacturerRepository(_context);
 }
Ejemplo n.º 14
0
 public UnitOfWork(ApplicationDbContext context)
 {
     this._context = context;
     Adresses      = new AddressRepository(_context);
     Wallets       = new WalletRepository(_context);
     Companies     = new CompanyRepository(_context);
     Products      = new ProductRepository(_context);
     Categories    = new CategoryRepository(_context);
     SubCategories = new SubCategoryRepository(_context);
     Transactions  = new TransactionRepository(_context);
 }
        public ActionResult AdminNavbar()
        {
            MainCategoryRepository     mainCategoryRepository     = new MainCategoryRepository();
            SubCategoryRepository      subCategoryRepository      = new SubCategoryRepository();
            FinalSubCategoryRepository finalSubCategoryRepository = new FinalSubCategoryRepository();
            CategoryViewModel          categoryViewModel          = new CategoryViewModel();

            categoryViewModel.mainCategories     = mainCategoryRepository.GetAll();
            categoryViewModel.subCatetories      = subCategoryRepository.GetAll();
            categoryViewModel.finalSubCategories = finalSubCategoryRepository.GetAll();
            return(PartialView("_AdminNavbar", categoryViewModel));
        }
Ejemplo n.º 16
0
 private void cbCategory_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         SubCategoryRepository r1 = new SubCategoryRepository();
         DataSet result           = r1.ListForCategory((int)cbCategory.SelectedValue);
         cbSubCategory.DataSource    = result.Tables[0];
         cbSubCategory.DisplayMember = "SubCategoryName";
         cbSubCategory.ValueMember   = "Id";
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 17
0
 public UnitOfWork(JooleContext Context)
 {
     this._context = Context;
     Users         = new UserRepository(_context);
     Projects      = new ProjectRepository(_context);
     Categories    = new CategoryRepository(_context);
     SubCategories = new SubCategoryRepository(_context);
     //ProductList = new ProductListRepository(_context);
     Products              = new ProductRepository(_context);
     ProductProperties     = new ProductPropertyRepository(_context);
     ProductPropertyValues = new ProductPropertyValueRepository(_context);
     ProdToProjRelations   = new ProductToProjectRepository(_context);
     TechSpecFilter        = new TechSpecFilterRepository(_context);
 }
Ejemplo n.º 18
0
 public SiteDataService(ILogger <SiteDataService> logger, IConfiguration configuration,
                        ApplicationDbContext context, CategoryRepository categoryRepository, ServicesRepository servicesRepository, ArticlesRepository articlesRepository, PartnerRepository partnerRepository,
                        SubCategoryRepository subCategoryRepository,
                        IgnoresRepository ignoresRepository)
 {
     _logger                = logger;
     _configuration         = configuration;
     _context               = context;
     _categoryRepository    = categoryRepository;
     _servicesRepository    = servicesRepository;
     _articlesRepository    = articlesRepository;
     _partnerRepository     = partnerRepository;
     _subCategoryRepository = subCategoryRepository;
     _ignoresRepository     = ignoresRepository;
 }
Ejemplo n.º 19
0
        public IActionResult AddProduct()
        {
            var model = new UIProductSupCategory();
            var c     = new SubCategoryRepository().GetAll("Id", "Name");

            if (c.Count > 0)
            {
                foreach (var item in c)
                {
                    model.Subcategores.Add(new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem(item.Name, item.Id.ToString()));
                }
            }

            return(View(model));
        }
Ejemplo n.º 20
0
        public IActionResult UpdateProduct(int id)
        {
            var pr    = repository.GetByColumName("Id", id);
            var model = new UIProductSupCategory(); model.Product = pr.FirstOrDefault();
            var c     = new SubCategoryRepository().GetAll("Id", "Name");

            if (c.Count > 0)
            {
                foreach (var item in c)
                {
                    model.Subcategores.Add(new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem(item.Name, item.Id.ToString()));
                }
            }

            return(View(model));
        }
Ejemplo n.º 21
0
        public void InsertAndSelect_ShouldEqualInserted()
        {
            // Arrange
            var dbModel = new SubCategoryModel()
            {
                Description = "voluptatem",
            };
            var expectedValue = new SubCategoryRepository(AppState.ConnectionString)
                                .Insert(dbModel);

            // Act
            var actualValue = new SubCategoryRepository(AppState.ConnectionString)
                              .Select(expectedValue)
                              .Id;

            // Assert
            Assert.AreEqual(expectedValue, actualValue);
        }
Ejemplo n.º 22
0
        public bool ChangeSubCategory(int id, int categoryId, bool value)
        {
            var subCategory = new SubCategoryRepository();
            var s           = subCategory.GetByColumName("Id", id).FirstOrDefault();

            if (s == null)
            {
                return(false);
            }
            if (value)
            {
                s.CategoryId = categoryId;
            }
            else
            {
                s.CategoryId = 0;
            }
            return(subCategory.Update(s, id));
        }
Ejemplo n.º 23
0
        public void InsertAndDelete_ShouldNoLongerExistAfterDelete()
        {
            // Arrange
            var expectedValue = 0;
            var dbModel       = new SubCategoryModel()
            {
                Description = "quibusdam",
            };

            // Act
            var newId = new SubCategoryRepository(AppState.ConnectionString).Insert(dbModel);

            new SubCategoryRepository(AppState.ConnectionString).Delete(newId);
            var actualValue = new SubCategoryRepository(AppState.ConnectionString)
                              .Select(newId)
                              .Id;

            // Assert
            Assert.AreEqual(expectedValue, actualValue);
        }
Ejemplo n.º 24
0
 public SubCategoryManager(SubCategoryRepository subCategoryRepository)
 {
     _subCategoryRepository = subCategoryRepository;
 }
Ejemplo n.º 25
0
 public SubCategoryManager()
 {
     _subCategoryRepository = new SubCategoryRepository();
 }
Ejemplo n.º 26
0
 public BaseCategoryManager()
 {
     _generalCategoryRepository = new GeneralCategoryRepository();
     _categoryRepository        = new CategoryRepository();
     _subCategoryRepository     = new SubCategoryRepository();
 }
Ejemplo n.º 27
0
 public SubCategoryBusiness(IUnitOfWork _unitOfWork)
 {
     unitOfWork            = _unitOfWork;
     subCategoryRepository = new SubCategoryRepository(unitOfWork);
 }
Ejemplo n.º 28
0
 public SubCategoryService()
 {
     _subCategoryRepository = new SubCategoryRepository();
 }
Ejemplo n.º 29
0
 public void Setup()
 {
     Repository = new SubCategoryRepository(Context);
 }