public void RegisteredShouldBeFalseWhenOrderIsCreated()
        {
            ProductTypeRepository repoPr = CreateRepositoryPr();
            OrderRepository       repoOr = CreateRepositoryOr();

            ProductType conditioner = repoPr.CreateProduct(8, 108, "Make your hair great again with this great conditioner!", 16);
            ProductType hairDye     = repoPr.CreateProduct(9, 571, "Don't like the disgusting color in your head? Change it now!", 52);

            List <int> productsId        = new List <int>();
            List <int> productsQuantity  = new List <int>();
            List <int> productsId1       = new List <int>();
            List <int> productsQuantity1 = new List <int>();

            productsId.Add(8);
            productsQuantity.Add(5);
            productsId.Add(9);
            productsQuantity.Add(10);

            productsId1.Add(9);
            productsQuantity1.Add(10);

            Order newOrder  = repoOr.InsertOrder(3, new DateTime(2016, 09, 20), new DateTime(2016, 09, 27), 1, productsQuantity, productsId, repoPr);
            Order newOrder1 = repoOr.InsertOrder(4, DateTime.Today, DateTime.Today, 2, productsQuantity1, productsId1, repoPr);

            Assert.IsFalse(newOrder.Registered);
            Assert.IsFalse(newOrder1.Registered);
        }
Example #2
0
        public VillageService(PlayerRepository playerRepository, VillageRepository villageRepository, BuildingRepository buildingRepository, BuildingTypeRepository buildingTypeRepository, UnitRepository unitRepository, UnitTypeRepository unitTypeRepository, ProductRepository productRepository, ProductTypeRepository productTypeRepository, ResourceRepository resourceRepository, ResourceTypeRepository resourceTypeRepository, BuildingListQuery buildingListQuery, BuildingTypeListQuery buildingTypeListQuery, ProductListQuery productListQuery, ProductTypeListQuery productTypeListQuery, ResourceTypeListQuery resourceTypeListQuery, UnitTypeListQuery unitTypeListQuery, VillageListQuery villageListQuery, AdventureRepository adventureRepository, AdventureTypeRepository adventureTypeRepository, AdventureTypeListQuery adventureTypeListQuery, UnitListQuery unitListQuery)
        {
            this.playerRepository  = playerRepository;
            this.villageRepository = villageRepository;

            this.buildingRepository     = buildingRepository;
            this.buildingTypeRepository = buildingTypeRepository;

            this.unitRepository     = unitRepository;
            this.unitTypeRepository = unitTypeRepository;

            this.productRepository     = productRepository;
            this.productTypeRepository = productTypeRepository;

            this.resourceRepository     = resourceRepository;
            this.resourceTypeRepository = resourceTypeRepository;

            this.adventureRepository     = adventureRepository;
            this.adventureTypeRepository = adventureTypeRepository;


            this.buildingTypeListQuery = buildingTypeListQuery;

            this.productTypeListQuery = productTypeListQuery;
            this.productListQuery     = productListQuery;

            this.resourceTypeListQuery  = resourceTypeListQuery;
            this.unitTypeListQuery      = unitTypeListQuery;
            this.adventureTypeListQuery = adventureTypeListQuery;
            this.villageListQuery       = villageListQuery;
            this.unitListQuery          = unitListQuery;
        }
Example #3
0
        public ActionResult GetAll()
        {
            using (var unit = GetUnitOfWork())
            {
                var repo = new ProductTypeRepository(unit, _defaultVendorID);

                var types = unit.Service <Product>().GetAll(c => _vendorIDs.Any(x => x == c.SourceVendorID) && c.IsConfigurable)
                            .Select(c => c.VendorItemNumber)
                            .ToList()
                            .Select(c => c.Split(new char[] { '-' }).Try(l => l[1], string.Empty))
                            .Distinct()
                            .ToList();

                var filledIn = repo.GetAll().Where(c => c.Type != null);

                return(List((from p in types
                             where !string.IsNullOrEmpty(p)
                             let existing = filledIn.FirstOrDefault(c => c.Type == p)
                                            select new ProductTypeViewModel()
                {
                    Type = p,
                    // Translation = existing == null ? string.Empty : (string.IsNullOrEmpty(existing.Translation) ? string.Empty : existing.Translation),
                    IsBra = existing == null ? false : existing.IsBra,
                    ProductType = existing == null ? string.Empty : (existing.ProductType == null ? string.Empty : existing.ProductType.ToString())
                }).AsQueryable()));
            }
        }
        public void ShouldGetOrdersFromToday()
        {
            ProductTypeRepository repoPr = CreateRepositoryPr();
            OrderRepository       repoOr = CreateRepositoryOr();

            ProductType conditioner = repoPr.CreateProduct(8, 108, "Make your hair great again with this great conditioner!", 16);
            ProductType hairDye     = repoPr.CreateProduct(9, 571, "Don't like the disgusting color in your head? Change it now!", 52);

            List <int> productsId        = new List <int>();
            List <int> productsQuantity  = new List <int>();
            List <int> productsId1       = new List <int>();
            List <int> productsQuantity1 = new List <int>();

            productsId.Add(8);
            productsQuantity.Add(5);
            productsId.Add(9);
            productsQuantity.Add(10);

            productsId1.Add(9);
            productsQuantity1.Add(10);

            Order newOrder  = repoOr.InsertOrder(3, new DateTime(2016, 09, 20), new DateTime(2016, 09, 27), 1, productsQuantity, productsId, repoPr);
            Order newOrder1 = repoOr.InsertOrder(4, DateTime.Today, DateTime.Today, 2, productsQuantity1, productsId1, repoPr);

            List <Order> listOfTodaysOrders = repoOr.CheckOrders(DateTime.Today, repoPr);

            Assert.AreEqual(1, listOfTodaysOrders.Count);
        }
Example #5
0
        public ActionResult SetTranslation(int _LanguageID, string type, string name)
        {
            try
            {
                using (var unit = GetUnitOfWork())
                {
                    var repo   = new ProductTypeRepository(unit, _defaultVendorID);
                    var record = repo.GetAll().FirstOrDefault(x => x.Type == type);

                    if (record == null)
                    {
                        repo.Add(new ProductTypeModel
                        {
                            Type = type
                        });
                    }
                    repo.Update(type, name, record.IsBra, (record != null && record.ProductType == null ? string.Empty : record.ProductType.ToString()), _LanguageID);

                    unit.Save();
                    return(Success("Update translation successfully"));
                }
            }
            catch (Exception e)
            {
                return(Failure("Something went wrong: ", e));
            }
        }
Example #6
0
        public void LoadOrder()
        {
            CustomerRepository repoCu = CreateRepositoryCu();

            repoCu.Clear();
            OrderRepository repoOr = CreateRepositoryOr();

            repoOr.Clear();

            Assert.AreEqual(0, repoCu.CountCustomers());
            Assert.AreEqual(0, repoOr.CountOrders());

            List <int> productsId       = new List <int>();
            List <int> productsQuantity = new List <int>();

            ProductTypeRepository repoPr = new ProductTypeRepository();

            ProductType hairSpray        = repoPr.CreateProduct(3, 68.00, "Supah stronk hair spray!", 10);
            ProductType hairStraightener = repoPr.CreateProduct(4, 172.62, "Very powerfull straightener for hair!", 30);

            productsId.Add(hairSpray.Id);
            productsQuantity.Add(5);
            productsId.Add(hairStraightener.Id);
            productsQuantity.Add(10);

            repoOr.InsertOrder(1, new DateTime(2015, 6, 10), new DateTime(2015, 7, 10), 1, productsQuantity, productsId, repoPr);

            Order loadedOrder = repoOr.Load(1);

            Assert.AreEqual(4, loadedOrder.ListOfOrderLines[1].ProductId);
        }
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            bool        passRequirements = true;
            String      producttypename  = txtProductTypeName.Text;
            ProductType pt = ProductTypeRepository.FindProductTypeByName(producttypename);

            if (txtProductTypeName.Text == "" || producttypename.Length < 5 || pt != null)
            {
                passRequirements = false;
                warningProductTypeName.Visible = true;
            }
            if (txtDescription.Text == "")
            {
                passRequirements           = false;
                warningDescription.Visible = true;
            }
            if (passRequirements == true)
            {
                String description = txtDescription.Text;

                ProductType newProductType = ProductTypeFactory.CreateProductType(producttypename, description);
                ProductTypeRepository.Create(newProductType);

                Response.Redirect("Home.aspx");
            }
        }
Example #8
0
        public void CheckIfTheProductDoesNotExist()
        {
            ProductTypeRepository repoPr   = CreateRepositoryPr();
            ProductType           scissors = repoPr.CreateProduct(6, 34.51, "Very Sharp scissors", 25);

            Assert.IsFalse(repoPr.CheckIfProductExists(7));
        }
        public void Clear()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            Assert.AreEqual(0, repo.CountProducts());
        }
Example #10
0
 public AddProductTypeModel(UserManager <Employee> userManager,
                            RoleManager <EmployeeRole> roleManager,
                            ProductTypeRepository companies)
 {
     this.userManager = userManager;
     this.roleManager = roleManager;
     this.companies   = companies;
 }
Example #11
0
 public ProductTypesModel(UserManager <Employee> userManager,
                          RoleManager <EmployeeRole> roleManager,
                          ProductTypeRepository venues)
 {
     this.userManager = userManager;
     this.roleManager = roleManager;
     this.venues      = venues;
 }
Example #12
0
        public void Delete(int id)
        {
            var ptr         = new ProductTypeRepository(_context);
            var productType = ptr.GetProductTypeById(id);
            var ptm         = new ProductTypeModification(_context);

            ptm.DeleteProductType(productType);
        }
Example #13
0
 public ProductTypeModel(UserManager <Employee> userManager,
                         RoleManager <EmployeeRole> roleManager,
                         ProductTypeRepository producttypes)
 {
     this.userManager  = userManager;
     this.roleManager  = roleManager;
     this.producttypes = producttypes;
 }
Example #14
0
 public ProductService(ProductRepository productRepository, ProductTypeRepository productTypeRepository, ResourceRepository resourceRepository, ResourceTypeRepository resourceTypeRepository, VillageRepository villageRepository, ProductListQuery productListQuery, ResourceListQuery resourceListQuery, BuildingListQuery buildingListQuery)
 {
     this.productRepository  = productRepository;
     this.resourceRepository = resourceRepository;
     this.productListQuery   = productListQuery;
     this.resourceListQuery  = resourceListQuery;
     this.buildingListQuery  = buildingListQuery;
 }
Example #15
0
        public static async Task <bool> CheckIfProductTypeExists(ProductTypeId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new ProductTypeRepository(context);

            return(await repository.ExistsAsync(id));
        }
Example #16
0
 public ProductController(ContextEntities context) : base(context)
 {
     context                   = _context;
     productRepository         = new ProductRepository(context);
     productTypeRepository     = new ProductTypeRepository(context);
     productCategoryRepository = new ProductCategoryRepository(context);
     websiteUserRepository     = new WebsiteUserRepository(context);
     productViewModel          = new ProductViewModel();
 }
        public void SaveAndCount()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            ProductType dryer = repo.CreateProduct(1, 263.00, "Very stronk pink hair dryer!!", 50);

            Assert.AreEqual(1, repo.CountProducts());
        }
Example #18
0
        public void CheckIfReturnsMinusOneWhenPassingAProductThatDoesNotExist()
        {
            ProductTypeRepository repoPr   = CreateRepositoryPr();
            ProductType           scissors = repoPr.CreateProduct(6, 34.51, "Very Sharp scissors", 25);

            int newAmount = repoPr.AddStock(7, 2);

            Assert.AreEqual(-1, newAmount);
        }
Example #19
0
 public static bool DeleteProductType(int id)
 {
     if (ProductTypeRepository.GetProductType(id) != null)
     {
         ProductTypeRepository.DeleteProductType(id);
         return(true);
     }
     return(false);
 }
Example #20
0
        public static bool CheckProductNameAvailability(string Name)
        {
            if (ProductTypeRepository.FindByName(Name) == null)
            {
                return(true);
            }

            return(false);
        }
Example #21
0
 private void CreateRepos()
 {
     mEntities        = new V308CMSEntities();
     ImageRepos       = new ImagesRepository(mEntities);
     ProductTypeRepos = new ProductTypeRepository(mEntities);
     ProductRepos     = new ProductRepository(mEntities);
     NewsRepos        = new NewsRepository(mEntities);
     MenuConfigRepos  = new MenuConfigRespository(mEntities);
 }
Example #22
0
        public void CheckIfReturnsMinusOneWhenPassingANegativeNumber()
        {
            ProductTypeRepository repoPr   = CreateRepositoryPr();
            ProductType           scissors = repoPr.CreateProduct(6, 34.51, "Very Sharp scissors", 25);

            int newAmount = repoPr.AddStock(6, -15);

            Assert.AreEqual(-1, newAmount);
        }
Example #23
0
 public ecvUnitOfWork(ecvDBContext context)
 {
     _context               = context;
     categoryRepository     = new CategoryRepository(_context);
     productRepository      = new ProductRepository(_context);
     productTypeRepository  = new ProductTypeRepository(_context);
     manufacturerRepository = new ManufacturerRepository(_context);
     vendorRepository       = new VendorRepository(_context);
 }
Example #24
0
 public HomeController()
 {
     characterRepository   = new CharacterRepository(DbContext);
     menuRepository        = new MenuRepository(DbContext);
     contentRepository     = new ContentRepository(DbContext);
     productTypeRepository = new ProductTypeRepository(DbContext);
     productRepository     = new ProductRepository(DbContext);
     contentTypeRepository = new ContentTypeRepository(DbContext);
 }
Example #25
0
        public async Task ProductType_inserted_to_database()
        {
            ProductType productType = await CreateValidProductType();

            var repository = new ProductTypeRepository(fixture.context);
            var sut        = await repository.LoadAsync(productType.Id);

            Assert.True(await repository.ExistsAsync(sut.Id));
            Assert.True(sut.Name.Length > 0);
        }
Example #26
0
        public void CheckIfCanAddStock()
        {
            ProductTypeRepository repoPr   = CreateRepositoryPr();
            ProductType           scissors = repoPr.CreateProduct(6, 34.51, "Very Sharp scissors", 25);

            int newAmount = repoPr.AddStock(6, 10);

            Assert.AreEqual(35, scissors.Amount);
            Assert.AreEqual(35, newAmount);
        }
        public void SaveAndLoad()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            ProductType dryer         = repo.CreateProduct(1, 263.00, "Very stronk pink hair dryer!!", 50);
            ProductType loadedProduct = repo.Load(dryer.Id);

            Assert.AreEqual(dryer.Id, loadedProduct.Id);
        }
        public void SaveAndCountTwoProducts()
        {
            ProductTypeRepository repo = CreateRepository();

            repo.Clear();
            ProductType dryer     = repo.CreateProduct(1, 263.00, "Very stronk pink hair dryer!!", 50);
            ProductType hairbrush = repo.CreateProduct(2, 39.00, "Very soft purple hair brush", 20);

            Assert.AreEqual(2, repo.CountProducts());
        }
        public void Delete(UpdateProductTypeCommand updatedProductTypeCommand, int id)
        {
            var repo = new ProductTypeRepository();
            var updatedProductType = new ProductType
            {
                Name = updatedProductTypeCommand.Name,
            };

            repo.DeleteProductType(updatedProductType, id);
        }
        public static ProductType DeleteProductType(int id)
        {
            ProductType pt = ProductTypeRepository.DeleteProductType(id);

            if (pt == null)
            {
                return(null);
            }

            return(pt);
        }
Example #31
0
 public UnitOfWork()
 {
     _context = new FxContext();
     Devices = new DeviceRepository(_context);
     Suppliers = new SupplierRepository(_context);
     Categories = new CategoryRepository(_context);
     PointNames = new PointNameRepository(_context);
     Sockets = new SocketRepository(_context);
     ProductTypes = new ProductTypeRepository(_context);
     IncludedProducts = new IncludedProductRepository(_context);
     SignalTypes = new SignalTypeRepository(_context);
     CableTypes = new CableTypeRepository(_context);
 }
Example #32
0
 public UnitOfWork(FxContext context)
 {
     _context = context;
     // client of unitOfWork uses same context on all properties
     Devices = new DeviceRepository(_context);
     Suppliers = new SupplierRepository(_context);
     Categories = new CategoryRepository(_context);
     PointNames = new PointNameRepository(_context);
     Sockets = new SocketRepository(_context);
     ProductTypes = new ProductTypeRepository(_context);
     IncludedProducts = new IncludedProductRepository(_context);
     SignalTypes = new SignalTypeRepository(_context);
     CableTypes = new CableTypeRepository(_context);
 }
Example #33
0
 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 WrapperProductType()
 {
     IoCManagerCore.Start();
     _productTypeRepository = (ProductTypeRepository) IoCManagerCore.Kernel.Get<IProductTypeRepository>();
     CollectionProductTypes = (List<ProductType>)_productTypeRepository.GetAll();
 }