Пример #1
0
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <IChannelRepository>();
            var model = new ApiChannelRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <string>())).Returns(Task.CompletedTask);
            var service = new ChannelService(mock.LoggerMock.Object,
                                             mock.RepositoryMock.Object,
                                             mock.ModelValidatorMockFactory.ChannelModelValidatorMock.Object,
                                             mock.BOLMapperMockFactory.BOLChannelMapperMock,
                                             mock.DALMapperMockFactory.DALChannelMapperMock);

            ActionResponse response = await service.Delete(default(string));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <string>()));
            mock.ModelValidatorMockFactory.ChannelModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <string>()));
        }
Пример #2
0
 public Task <int> Delete(IEnumerable <DeletedChannel> channels) => Service.Delete(channels);
Пример #3
0
        public void TestDelete()
        {
            Channel channel = _service.Read(_channelID);

            _service.Delete(channel);
        }
Пример #4
0
        public ActionResult ImportPackage(DeploymentViewModel.ImportViewModel importForm)
        {
            var           model         = _deploymentViewModelBuilder.Build(ShowExport());
            StructureInfo structureInfo = null;
            PackageInfo   packageInfo   = null;

            if (!ValidateImportForm(importForm))
            {
                return(View(nameof(Index), model));
            }
            _package.Type = importForm.PackageName;

            try
            {
                structureInfo = _package.GetStructureInfo();
                structureInfo.CreateExampleProducts = importForm.CreateExampleProducts;

                packageInfo      = _package.CreatePackageInfo(structureInfo, importForm.Name, importForm.DomainName);
                model.ShowImport = true;
                model.CanImport  = true;

                Solution.Instance.SearchService.IndexJobConsumer.Stop();

                _packageService.Import(structureInfo, packageInfo);
                _structureInfoService.UpdatePropertyReferences(structureInfo, packageInfo);
                model.ImportMessage = "accelerator.deployment.import.success".AsAngularResourceString();
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Package installation error.");
                model.ImportMessage = "accelerator.deployment.error".AsAngularResourceString();
                try
                {
                    foreach (var variant in structureInfo.ProductCatalog.Variants)
                    {
                        var newVariant = _variantService.Get(structureInfo.Id(variant.SystemId));
                        if (newVariant != null)
                        {
                            _variantService.Delete(newVariant);
                        }
                    }

                    foreach (var product in structureInfo.ProductCatalog.BaseProducts)
                    {
                        var newProduct = _baseProductService.Get(structureInfo.Id(product.SystemId));
                        if (newProduct != null)
                        {
                            _baseProductService.Delete(newProduct);
                        }
                    }

                    foreach (var category in structureInfo.ProductCatalog.Categories)
                    {
                        var newCategory = _categoryService.Get(structureInfo.Id(category.SystemId));
                        if (newCategory != null)
                        {
                            _categoryService.Delete(newCategory);
                        }
                    }

                    _channelService.Delete(packageInfo.Channel);
                    _marketService.Delete(packageInfo.Market);
                    _websiteService.Delete(packageInfo.Website);
                    _assortmentService.Delete(packageInfo.Assortment);
                    _folderService.Delete(packageInfo.Folder);
                    _inventoryService.Delete(packageInfo.Inventory);
                    _priceListService.Delete(packageInfo.PriceList);
                }
                catch (Exception ee)
                {
                    _logger.LogError(ee, "Package installation cleanup error.");
                }
            }
            finally
            {
                Solution.Instance.SearchService.IndexJobConsumer.Start();
            }

            return(View(nameof(Index), model));
        }
Пример #5
0
 public ActionResult Delete(Guid ID)
 {
     _channelService.Delete(ID);
     _channelService.Save();
     return(RedirectToAction("Listele"));
 }