Пример #1
0
 protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteBrand")
     {
         BrandService.DeleteBrand(SQLDataHelper.GetInt(e.CommandArgument));
     }
 }
        public JsonResult Delete(int brandId)
        {
            BrandService oBrandService = new BrandService();
            bool         Result        = oBrandService.DeleteBrand(brandId);

            return(Json(new { Result = Result }));
        }
Пример #3
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);
        }
Пример #4
0
 protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteBrand")
     {
         BrandService.DeleteBrand(Convert.ToInt32(e.CommandArgument));
     }
 }
Пример #5
0
 protected void lbDeleteBrand_Click(object sender, EventArgs e)
 {
     BrandService.DeleteBrand(GetIntState(BRAND_ID));
     ResetScreen();
     PopulateBrandInfo(AppConstant.DEFAULT_BRAND);
     enbNotice.Message    = "Brand was deleted successfully.";
     hfCurrentPanel.Value = "general";
     LoadBrands();
 }
Пример #6
0
        protected void bntClearShop_OnClick(object sender, EventArgs e)
        {
            if (TrialService.IsTrialEnabled)
            {
                foreach (var category in CategoryService.GetCategories().Where(category => category.ID != 0))
                {
                    CategoryService.DeleteCategoryAndPhotos(category.ID);
                }

                foreach (var productId in ProductService.GetAllProductIDs())
                {
                    ProductService.DeleteProduct(productId, false);
                }

                foreach (var property in PropertyService.GetAllProperties())
                {
                    PropertyService.DeleteProperty(property.PropertyId);
                }

                foreach (var brand in BrandService.GetBrands())
                {
                    BrandService.DeleteBrand(brand.ID);
                }


                foreach (var paymentId in PaymentService.GetAllPaymentMethodIDs())
                {
                    PaymentService.DeletePaymentMethod(paymentId);
                }

                foreach (var shippingId in ShippingMethodService.GetAllShippingMethodIds())
                {
                    ShippingMethodService.DeleteShippingMethod(shippingId);
                }

                foreach (var news in NewsService.GetNews())
                {
                    NewsService.DeleteNews(news.ID);
                }

                foreach (var newsCstegory in NewsService.GetNewsCategories())
                {
                    NewsService.DeleteNewsCategory(newsCstegory.NewsCategoryID);
                }

                CategoryService.RecalculateProductsCountManual();
                CategoryService.SetCategoryHierarchicallyEnabled(0);
                CacheManager.Clean();

                TrialService.TrackEvent(TrialEvents.DeleteTestData, string.Empty);
            }
        }
Пример #7
0
        public void RemoveBrand_IncorrectID_ExpectArgumentException(int ID)
        {
            // arrange
            BrandService service = new BrandService(repoMock.Object, validatorMock.Object);

            // act + assert
            var ex = Assert.Throws <ArgumentException>(() => service.DeleteBrand(ID));

            // assert
            Assert.Equal("Incorrect ID entered", ex.Message);
            repoMock.Verify(repo => repo.DeleteBrandInRepo(It.Is <int>(id => id == ID)), Times.Never);
            repoMock.Verify(repo => repo.ReadBrandById(It.Is <int>(id => id == ID)), Times.Never);
        }
Пример #8
0
        public async Task<IActionResult> DeleteBrand([FromRoute] Guid id)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var brand = await brandService.GetById(id);
            if (brand == null)
            {
                return NotFound();
            }

            await brandService.DeleteBrand(id);

            return Ok(brand);
        }
Пример #9
0
        public void RemoveBrand_BrandDoesNotExist_ExpectArgumentException()
        {
            // arrange

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

            Brand brand = new Brand()
            {
                ID        = 1,
                BrandName = "Ølværket"
            };

            // act + assert
            var ex = Assert.Throws <InvalidOperationException>(() => service.DeleteBrand(brand.ID));

            // assert
            Assert.Equal("No brand with such ID found", ex.Message);
            repoMock.Verify(repo => repo.ReadBrandById(It.Is <int>(ID => ID == brand.ID)), Times.Once);
            repoMock.Verify(repo => repo.DeleteBrandInRepo(It.Is <int>(ID => ID == brand.ID)), Times.Never);
        }
Пример #10
0
 protected void lbDeleteSelected_Click(object sender, EventArgs e)
 {
     if ((_selectionFilter != null) && (_selectionFilter.Values != null))
     {
         if (!_inverseSelection)
         {
             foreach (var id in _selectionFilter.Values)
             {
                 BrandService.DeleteBrand(SQLDataHelper.GetInt(id));
             }
         }
         else
         {
             var itemsIds = _paging.ItemsIds <int>("BrandID as ID");
             foreach (var brandId in itemsIds.Where(brandId => !_selectionFilter.Values.Contains(brandId.ToString(CultureInfo.InvariantCulture))))
             {
                 BrandService.DeleteBrand(brandId);
             }
         }
     }
 }
Пример #11
0
        public void RemoveBrand_ValidExistingBrand()
        {
            // arrange
            Brand brand = new Brand()
            {
                ID        = 1,
                BrandName = "Ølværket"
            };

            brandDatabase.Add(brand.ID, brand);

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

            // act
            service.DeleteBrand(brand.ID);

            // assert
            repoMock.Verify(repo => repo.ReadBrandById(It.Is <int>(ID => ID == brand.ID)), Times.Once);
            repoMock.Verify(repo => repo.DeleteBrandInRepo(It.Is <int>(ID => ID == brand.ID)), Times.Once);
            Assert.Null(repoMock.Object.ReadBrandById(brand.ID));
        }
Пример #12
0
 public static int DeleteBrand(string bid)
 {
     return(BrandService.DeleteBrand(bid));
 }