예제 #1
0
        private void OnBrandsLoad(string brandName)
        {
            if (string.IsNullOrEmpty(brandName))
            {
                _brandQueryCriteria = new QueryAll {
                    PageIndex = 1, PageSize = 100
                };
            }
            else
            {
                _brandQueryCriteria = new QueryByName {
                    PageIndex = 1, PageSize = 100, Name = brandName
                };
            }

            var result = BrandService.Query(_brandQueryCriteria);
            var brands = new ObservableCollection <Brand>(result.Data);

            FilterBrands(brands);
            Brands = new ObservableCollection <Brand>(brands);

            if (Model.Brands == null)
            {
                Model.Brands = new List <Brand>();
            }

            Model.Brands.ForEach(brand =>
            {
                brand.IsSelected = true;
                int index        = 0;
                PerformActionOnUIThread(() => Brands.Insert(index++, brand));
            });
        }
예제 #2
0
        public PartialViewResult BrandList()
        {
            BrandService brand = new BrandService();

            ViewBag.List = brand.SelectAll();
            return(PartialView());
        }
예제 #3
0
        static void Main(string[] args)
        {
            ICarService      carService      = new CarService(new EfCarDal());
            IBrandService    brandService    = new BrandService(new EfBrandDal());
            IRentService     rentService     = new RentService(new EfRentDal());
            IColorService    colorService    = new ColorService(new EfColorDal());
            ICustomerService customerService =
                new CustomerService(new EfCustomerDal());
            IUserService userService = new UserService(new EfUserDal());

            //var brands = new EfBrandDal();
            //Console.WriteLine(brands.Get(p => p.Id == 325) == null ? "No record" : "Found");

            //RentDetailsDtoTest(rentService);
            //CarDetailsDtoTest(carService);            //OK.
            //BrandServiceTest(brandService);           //OK.
            //CarServiceTest(carService);               //OK.
            //ColorServiceTest(colorService);           //OK.
            //CustomerServiceTest(customerService);     //OK.
            //RentServiceTest(rentService);             //OK.
            //UserListTest(userService);                //OK.
            //AddNewUserTest(userService);              //OK.
            //AddNewCustomer(customerService);
            //AddNewRentTest(rentService);                //OK.
            DeleteRentTest(rentService);
            //RemoveUserTest(userService);
        }
예제 #4
0
        public void GetBrandFilterSearch_CorrectPaging()
        {
            // arrange
            var brand1 = new Brand {
                ID = 1
            };
            var brand2 = new Brand {
                ID = 2
            };

            brandDatabase.Add(brand1.ID, brand1);
            brandDatabase.Add(brand2.ID, brand2);

            var expected = new List <Brand>()
            {
                brand1, brand2
            };
            int expectedSize = expected.Count;

            Filter filter = new Filter {
                CurrentPage = 1, ItemsPrPage = 2
            };
            BrandService service = new BrandService(repoMock.Object, validatorMock.Object);

            // act
            var result = service.GetBrandFilterSearch(filter);

            // assert
            Assert.Equal(expected, result.List);
            Assert.Equal(expectedSize, result.totalItems);
            repoMock.Verify(repo => repo.ReadBrandsFilterSearch(It.Is <Filter>(f => f == filter)), Times.Once);
        }
예제 #5
0
        public ActionResult FindPageList(string title, int?classfyId)
        {
            var count = 0;
            var list  = BrandService.GetPageList(Request.Params, out count);

            return(ToDataGrid(list, count));
        }
예제 #6
0
        protected void lbUploadImage_Click(object sender, EventArgs e)
        {
            if (fuImage.HasFile)
            {
                // Create new brand media row to get id
                BrandMedia newMedia = new BrandMedia();
                newMedia.BrandId       = GetIntState(BRAND_ID);
                newMedia.MediaFilename = fuImage.FileName;

                newMedia.Id = BrandService.InsertBrandMedia(newMedia);

                // Save image
                string filename = newMedia.Id.ToString() + Path.GetExtension(fuImage.FileName).ToLower();
                fuImage.SaveAs(MediaSettings.BrandMediaLocalPath + filename);

                // Update brand media
                newMedia.MediaFilename = filename;
                BrandService.UpdateBrandMedia(newMedia);

                PopulateBrandInfo(GetIntState(BRAND_ID));

                hfCurrentPanel.Value = "media";

                enbNotice.Message = "Image was added successfully.";
            }
            else
            {
                enbNotice.Message = "Sorry, there is no image to upload.";
            }
        }
        public async Task EditBrandAsync_ShouldEditBrandById()
        {
            var options = new DbContextOptionsBuilder <TechAndToolsDbContext>()
                          .UseInMemoryDatabase(databaseName: "EditBrandAsync_ShouldEditBrandById")
                          .Options;

            TechAndToolsDbContext context = new TechAndToolsDbContext(options);

            await SeedData(context);

            IBrandService brandService = new BrandService(context);

            Brand expectedData = context.Brands.First();

            expectedData.Name         = "New Name";
            expectedData.LogoUrl      = "New Logo";
            expectedData.OfficialSite = "New Site";

            BrandServiceModel serviceModel = expectedData.To <BrandServiceModel>();

            BrandServiceModel actualData = await brandService.EditAsync(serviceModel);

            Assert.Equal(expectedData.Id, actualData.Id);
            Assert.Equal(expectedData.Name, actualData.Name);
            Assert.Equal(expectedData.LogoUrl, actualData.LogoUrl);
            Assert.Equal(expectedData.OfficialSite, actualData.OfficialSite);
            Assert.NotNull(actualData);
            Assert.NotNull(actualData.Products);
        }
예제 #8
0
 public HelperController()
 {
     _brandService=new BrandService();
     _configService = new ConfigService();
     _productService=new ProductService();
     _colorService=new ColorService();
 }
예제 #9
0
        public JsonResult GetBrand(string bid)
        {
            long        brandid = bid.ToLong(0);
            BrandEntity result  = BrandService.GetBrandById(brandid) ?? new BrandEntity();

            return(Json(result));
        }
예제 #10
0
        public static BrandService Return(SKAutoDbContext db)
        {
            var brandRepository = new Repository <Brand>(db);
            var brandService    = new BrandService(brandRepository);

            return(brandService);
        }
예제 #11
0
        private static void GetBrandById(BrandService brandService, int brandId)
        {
            var brand = brandService.GetById(brandId);

            Console.WriteLine("Brand Id:" + brandId);
            Console.WriteLine(brand.Data.Name);
        }
예제 #12
0
        private void Populate(TreeNode node)
        {
            if (BrandId != 0)
            {
                IList <BrandCategory> brandCategories = new List <BrandCategory>();

                if (node.Value == ROOT_INDEX.ToString())
                {
                    node.Text       = BrandService.GetBrandById(BrandId).Name;
                    brandCategories = BrandService.GetBrandCategoriesByBrandParent(BrandId, ROOT_INDEX);
                }
                else
                {
                    brandCategories = BrandService.GetBrandCategoriesByParentId(Convert.ToInt32(node.Value));
                }

                if (brandCategories.Count > 0)
                {
                    PopulateCategories(node, brandCategories);
                }
                else
                {
                    node.SelectAction = TreeNodeSelectAction.Select;
                }
            }
        }
예제 #13
0
        public ActionResult Import(ImportSet imp)
        {
            imp.TableName = "ProductBrand";
            var op = BrandService.Import(imp, Request.Files, Request["FieldName"], Request["ColumnName"]);

            return(new OpActionResult(op));
        }
예제 #14
0
        public void ReadAllBrandsSecureReturnsAList()
        {
            var brandRepo   = new Mock <IBrandRepository>();
            var speakerRepo = new  Mock <ISpeakerRepository>();

            IBrandService brandService = new BrandService(brandRepo.Object, speakerRepo.Object);
            var           filter       = new Filter()
            {
                ItemsPrPage = 1,
                CurrentPage = 1,
                Price       = 10,
                Brand       = "Bose"
            };

            brandRepo.Setup(x => x.ReadAllBrands(filter)).Returns(new List <Brand>()
            {
                new Brand()
                {
                    BrandId      = 1,
                    SpeakerBrand = "Bose"
                }
            });
            var list = brandService.ReadAllBrands(filter);

            Assert.NotEmpty(list);
        }
예제 #15
0
        public void DeleteBrandSecureRepoIsCalled()
        {
            var brandRepo   = new Mock <IBrandRepository>();
            var speakerRepo = new Mock <ISpeakerRepository>();

            IBrandService brandService = new BrandService(brandRepo.Object, speakerRepo.Object);

            var brand = new Brand()
            {
                BrandId      = 1,
                SpeakerBrand = "Bose"
            };

            var isCalled = false;

            brandRepo.Setup(x => x.ReadBrandById(It.IsAny <int>())).Returns(new Brand()
            {
                BrandId      = 1,
                SpeakerBrand = "Bose"
            });
            brandRepo.Setup(x => x.DeleteBrand(It.IsAny <int>())).Callback(() => isCalled = true);

            brandService.DeleteBrand(brand.BrandId);
            Assert.True(isCalled);
        }
예제 #16
0
 protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteBrand")
     {
         BrandService.DeleteBrand(Convert.ToInt32(e.CommandArgument));
     }
 }
        public async Task CreateBeer_GivenAValidBeer_ShouldCallCreateBeerWithACorrectlyMappedBeerEntity()
        {
            //Arrange
            var beer = new Beer {
                Name = "Test name"
            };
            var beerEntity = beer.ToEntity();

            var mockedValidation = new Mock <IBrandValidation>();

            mockedValidation.Setup(validation => validation.ValidateBeer(It.IsAny <Beer>()));

            var mockedDataAccess = new Mock <IBrandDataAccess>();

            mockedDataAccess.Setup(dataAccess => dataAccess.CreateBeer(It.IsAny <BeerEntity>()))
            .ReturnsAsync(Guid.Empty);

            var brandService = new BrandService(mockedDataAccess.Object, mockedValidation.Object);

            //Act
            var result = await brandService.CreateBeer(beer);

            //Assert
            mockedDataAccess.Verify(dataAccess => dataAccess.CreateBeer(It.Is <BeerEntity>(entity => Serialize(entity) == Serialize(beerEntity))), Times.Once);
        }
        static void Main(string[] args)
        {
            using var data = new PetStoreDbContext();
            var brandService = new BrandService(data);

            //brandService.Create("Purrina");

            //var brandWithToys = brandService.FindByIdWithToys(1);

            //var foodService = new FoodService(data);
            //foodService.BuyFromDistributor("Cat food", 0.350, 1.10M, 0.3M, DateTime.Now, 1, 1);

            //var toyService = new ToyService(data);
            //toyService.BuyToyFromDistributor("Ball", null, 3.50M, 0.3M, 1,1);

            var userService = new UserService(data);
            //var foodService = new FoodService(data, userService);
            //int userId = userService.RegisterUser("Pesho", "*****@*****.**");
            //foodService.SellFoodToUser(1, userId);

            //var toyService = new ToyService(data, userService);
            //toyService.SellToyToUser(1,1);

            //var breedService = new BreedService(data);
            //breedService.Add("Persian");

            //var petService = new PetService(data, new CategoryService(data), breedService, userService);
            //petService.BuyPet(Gender.Female, DateTime.Now.AddDays(-30), 0M, "small kitten with no habits", 1, 1);
            //petService.SellPet(1,1);

            //SeedDatabaseWithPetsCtagoriesAndBreeds(data);
        }
예제 #19
0
 public MainWindow()
 {
     InitializeComponent();
     _equipmentService = new EquipmentService();
     _brandService     = new BrandService();
     _toolService      = new ToolService();
 }
        // GET: Brands
        public ActionResult Index()
        {
            BrandService             oBrandService = new BrandService();
            IEnumerable <BrandModel> brands        = oBrandService.GetAllBrands();

            return(View(brands));
        }
예제 #21
0
        private async Task <String> GetBrandsHtml(string designName, int take, int imageWidth, int imageHeight)
        {
            string returnHtml;

            take = take == 0 ? GetSettingValueInt("BrandsPartial_ItemsNumber", 50) : take;
            var pageDesignTask = PageDesignService.GetPageDesignByName(StoreId, designName);
            var brandsTask     = BrandService.GetBrandsAsync(StoreId, take, true);

            BrandHelper.StoreSettings = GetStoreSettings();
            BrandHelper.ImageWidth    = imageWidth == 0 ? GetSettingValueInt("BrandsPartial_ImageWidth", 50) : imageWidth;
            BrandHelper.ImageHeight   = imageHeight == 0 ? GetSettingValueInt("BrandsPartial_ImageHeight", 50) : imageHeight;

            await Task.WhenAll(pageDesignTask, brandsTask);

            var pageDesign = pageDesignTask.Result;
            var brands     = brandsTask.Result;

            if (pageDesign == null)
            {
                throw new Exception("PageDesing is null");
            }


            var pageOuput = BrandHelper.GetBrandsPartial(brands, pageDesign);

            returnHtml = pageOuput.PageOutputText;

            return(returnHtml);
        }
        public JsonResult Delete(int brandId)
        {
            BrandService oBrandService = new BrandService();
            bool         Result        = oBrandService.DeleteBrand(brandId);

            return(Json(new { Result = Result }));
        }
예제 #23
0
        public async Task <ActionResult> Brands()
        {
            var sitemapItems = new List <SitemapItem>();

            String key = String.Format("BrandsSiteMap-{0}", StoreId);

            ProductSitemapItemCache.TryGet(key, out sitemapItems);

            if (sitemapItems == null)
            {
                sitemapItems = new List <SitemapItem>();
                var brandsTask = BrandService.GetBrandsAsync(StoreId, null, true);
                await Task.WhenAll(brandsTask);

                var brands = brandsTask.Result;
                foreach (var brand in brands)
                {
                    var brandDetailLink = LinkHelper.GetBrandIdRouteValue(brand);
                    var siteMap         = new SitemapItem(Url.AbsoluteAction("detail", "brands", new { id = brandDetailLink }),
                                                          changeFrequency: SitemapChangeFrequency.Monthly, priority: 1.0);
                    sitemapItems.Add(siteMap);
                }
                ProductSitemapItemCache.Set(key, sitemapItems, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.CacheLongSeconds));
            }
            return(new SitemapResult(sitemapItems));
        }
예제 #24
0
        public void GetAllBrands(int brandCount)
        {
            // arrange
            Brand brand1 = new Brand {
                ID = 1
            };
            Brand brand2 = new Brand {
                ID = 2
            };
            List <Brand> brands = new List <Brand>()
            {
                brand1, brand2
            };

            var expected = brands.GetRange(0, brandCount);

            foreach (var brand in expected)
            {
                brandDatabase.Add(brand.ID, brand);
            }

            BrandService service = new BrandService(repoMock.Object, validatorMock.Object);

            // act
            var result = service.GetAllBrands();

            // assert
            Assert.Equal(expected, result);
            repoMock.Verify(repo => repo.ReadBrands(), Times.Once);
        }
예제 #25
0
 public ProductController()
 {
     productService = new ProductService();
     brandService   = new BrandService();
     commentService = new CommentService();
     orderService   = new OrderService();
 }
예제 #26
0
        public void GetBrandFilterSearch_IndexOutOfBounds_ExpectInvalidDataException()
        {
            // arrange
            repoMock.Setup(repo => repo.ReadBrandsFilterSearch(It.IsAny <Filter>())).Returns(() => throw new InvalidDataException("Index out of bounds"));

            var brand1 = new Brand {
                ID = 1
            };
            var brand2 = new Brand {
                ID = 2
            };

            brandDatabase.Add(brand1.ID, brand1);
            brandDatabase.Add(brand2.ID, brand2);

            Filter filter = new Filter {
                CurrentPage = 2, ItemsPrPage = 2
            };
            BrandService service = new BrandService(repoMock.Object, validatorMock.Object);

            // act
            var ex = Assert.Throws <InvalidDataException>(() => service.GetBrandFilterSearch(filter));

            // assert
            Assert.Equal("Index out of bounds", ex.Message);
            repoMock.Verify(repo => repo.ReadBrandsFilterSearch(It.Is <Filter>(f => f == filter)), Times.Once);
        }
예제 #27
0
        public static void Main(string[] args)
        {
            var carService = new CarService(new EfCarDal());

            AddNewCar(carService);
            GetAllCar(carService);
            GetCarById(carService, 1);
            UpdateCar(carService);
            DeleteCar(carService);

            var brandService = new BrandService(new EfBrandDal());

            AddNewBrand(brandService);
            GetAllBrand(brandService);
            GetBrandById(brandService, 1);
            UpdateBrand(brandService);
            DeleteBrand(brandService);

            var colorService = new ColorService(new EfColorDal());

            AddNewColor(colorService);
            GetAllColor(colorService);
            GetColorById(colorService, 1);
            UpdateColor(colorService);
            DeleteColor(colorService);

            Console.ReadLine();
        }
예제 #28
0
 protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteBrand")
     {
         BrandService.DeleteBrand(SQLDataHelper.GetInt(e.CommandArgument));
     }
 }
예제 #29
0
        protected void gvBrands_PreRender(object sender, EventArgs e)
        {
            var brandId = GetIntState(BRAND_ID);

            PopulateBrandInfo(brandId);

            if (GetIntState(BRAND_ID) == -1)
            {
                lbDeleteBrand.Visible = false;
                ltlTitle.Text         = "New Brand";
                //hfCurrentPanel.Value = "general";
            }
            else
            {
                var brand = BrandService.GetBrandById(brandId);
                lbDeleteBrand.Visible = true;
                ltlTitle.Text         = string.Format("{0} (ID: {1}) {2} {3}",
                                                      brand.Name,
                                                      brand.Id,
                                                      string.Format("<a href='{0}' target='_blank'><i class='fa fa-external-link' aria-hidden='true'></i></a>", AdminStoreUtility.GetBrandUrl(brand.UrlRewrite)),
                                                      brand.Enabled ? null : "<i class='fa fa-eye-slash' aria-hidden='true' title='offline'></i>");
            }

            if (GetIntState(DISPLAY) == VIEW_PRODUCT)
            {
                hfCurrentPanel.Value = "products";
            }

            if (gvBrands.TopPagerRow != null)
            {
                gvBrands.TopPagerRow.Visible = true;
                ((TextBox)gvBrands.HeaderRow.FindControl("txtBrandFilterId")).Text   = GetStringState(BRAND_ID_FILTER);
                ((TextBox)gvBrands.HeaderRow.FindControl("txtBrandFilterName")).Text = GetStringState(BRAND_NAME_FILTER);
            }
        }
예제 #30
0
        public ActionResult Index()
        {
            brandService = new BrandService();
            var model = brandService.GetAll().ToList();

            return(View(model));
        }
예제 #31
0
        private void PopulateBrandInfo(int brandId)
        {
            SetState(BRAND_ID, brandId);
            Brand brand = BrandService.GetBrandById(brandId);

            if (brand != null)
            {
                SetState(BRAND_NAME, brand.Name);

                txtName.Text = Server.HtmlDecode(brand.Name);

                if (brand.FlashImage == string.Empty)
                {
                    imgLogo.Visible      = false;
                    fuLogo.Visible       = true;
                    cbRemoveLogo.Visible = false;
                }
                else
                {
                    imgLogo.Src          = "/get_image_handler.aspx?type=brand&img=" + brand.FlashImage;
                    imgLogo.Alt          = brand.FlashImage;
                    imgLogo.Visible      = true;
                    fuLogo.Visible       = false;
                    cbRemoveLogo.Visible = true;
                }

                txtDesc.Text         = brand.Description;
                txtUrlKey.Text       = brand.UrlRewrite;
                cbMicrosite.Checked  = brand.HasMicrosite;
                txtMetaDesc.Text     = brand.MetaDescription;
                txtMetaTitle.Text    = brand.MetaTitle;
                txtMetaKeywords.Text = brand.MetaKeywords;

                ddlDelivery.SelectedIndex = -1;
                ddlDelivery.Items.FindByValue(brand.Delivery.Id.ToString()).Selected = true;
                cbEnforceStockCount.Checked = brand.EnforceStockCount;
                cbEnabled.Checked           = brand.Enabled;

                gvBanners.DataSource = brand.BrandMedias;
                gvBanners.DataBind();

                LoadNewFeaturedProducts();
            }

            if (brandId == AppConstant.DEFAULT_BRAND)
            {
                SetState(MODE, NEW);
                SetState(CHOSEN_FILTER, ANY);
                lbSaveImage.Enabled = false;
            }
            else
            {
                SetState(MODE, EDIT);
                SetState(CHOSEN_FILTER, YES);
                lbSaveImage.Enabled = true;
            }

            LoadProducts();
        }
예제 #32
0
 public AdminController()
 {
     _colorService = new ColorService();
     _categoryService = new CategoryService();
     _productService = new ProductService();
     _configService = new ConfigService();
     _orderService = new OrderService();
     _userService = new UserService();
     _brandService = new BrandService();
 }
예제 #33
0
        void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (Brands == null)
            {
                BrandService service = new BrandService();
                Brands = service.GetListBrand();
            }
            filterContext.Controller.ViewBag.Brands = Brands;
            filterContext.Controller.ViewBag.LinkService = LinkService;

            this.OnActionExecuting(filterContext);
        }
예제 #34
0
        void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (Brands == null)
            {
                try
                {
                    BrandService service = new BrandService();
                    Brands = service.GetListBrand();
                }
                catch (Exception)
                {
                    AccessTokenService tkService = new AccessTokenService();
                    tkService.UpdateToken();

                    BrandService service = new BrandService();
                    Brands = service.GetListBrand();
                }
            }
            filterContext.Controller.ViewBag.Brands = Brands;
            filterContext.Controller.ViewBag.LinkService = LinkService;

            this.OnActionExecuting(filterContext);
        }
 public JsonResult GetBrandByCommodityIdAndCommodityTypeId(int commId, int commTypeId)
 {
     var BrandSvc = new BrandService();
     var result = BrandSvc.GetBrandByCommodity(commId, commTypeId);
     return Json(result);
 }