コード例 #1
0
        public DeleteProductViewModel GetDeleteDetskaViewModel(int id)
        {
            Detska detska = this.Context.Detski.Find(id);
            DeleteProductViewModel model = Mapper.Map <Detska, DeleteProductViewModel>(detska);

            return(model);
        }
コード例 #2
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var product = _productsRepository.GetById((int)id);

            if (product == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var viewModel = new DeleteProductViewModel()
            {
                Id          = product.Id,
                ImageUrl    = product.ImageUrl,
                Ingredients = product.Ingredients.ToList(),
                Name        = product.Name,
                Price       = product.Price,
                Type        = product.Type
            };

            return(View(viewModel));
        }
コード例 #3
0
        public DeleteProductViewModel GetDeleteSpalnqViewModel(int id)
        {
            Spalnq spalnq = this.Context.Spalni.Find(id);
            DeleteProductViewModel model = Mapper.Map <Spalnq, DeleteProductViewModel>(spalnq);

            return(model);
        }
コード例 #4
0
        public DeleteProductViewModel GetDeletePortmantoViewModel(int id)
        {
            Portmanto portmanto          = this.Context.Portmanta.Find(id);
            DeleteProductViewModel model = Mapper.Map <Portmanto, DeleteProductViewModel>(portmanto);

            return(model);
        }
コード例 #5
0
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var product = await _bll.ProductService.GetProductAsync(productId : id.Value);

            if (product == null)
            {
                return(NotFound());
            }

            var vm = new DeleteProductViewModel()
            {
                Price          = product.CurrentPrice,
                Description    = product.Description,
                ProductId      = product.Id,
                OrganizationId = product.OrganizationId,
                ProductName    = product.ProductName
            };


            return(View(vm));
        }
コード例 #6
0
        public DeleteProductViewModel GetDeleteKuhnqViewModel(int id)
        {
            Kuhnq kuhnq = this.Context.Kuhni.Find(id);
            DeleteProductViewModel model = Mapper.Map <Kuhnq, DeleteProductViewModel>(kuhnq);

            return(model);
        }
コード例 #7
0
        public DeleteProductViewModel GetDeleteMasaViewModel(int id)
        {
            Masa masa = this.Context.Masi.Find(id);
            DeleteProductViewModel model = Mapper.Map <Masa, DeleteProductViewModel>(masa);

            return(model);
        }
コード例 #8
0
    public IActionResult DeleteProduct(DeleteProductViewModel deleteProductViewModel)
    {
        var productToDel = _productRepository.GetOne(deleteProductViewModel.ProductId);

        if (productToDel == null)
        {
            return(View("ProductNotFound", deleteProductViewModel.ProductId));
        }

        var store = _productRepository.GetStoreOfSpecificProduct(productToDel.Id);

        if (store == null)
        {
            return(View("StoreNotFound", Guid.Empty));
        }

        var categoryWithStoreSpecificProducts =
            store.Categories.First(e => e.Id.Equals(productToDel.CategoryId));
        var storeAndCategorySpecificProducts = categoryWithStoreSpecificProducts.Products.Where(product =>
                                                                                                product.Name.Equals(productToDel.Name) && product.ProductStatus.Equals(productToDel.ProductStatus))
                                               .ToList();

        if (storeAndCategorySpecificProducts.Count == 0)
        {
            return(RedirectToAction(IndexAction, DefaultController));
        }

        foreach (var product in storeAndCategorySpecificProducts)
        {
            _productRepository.DeleteOne(product.Id);
        }


        return(RedirectToAction(IndexAction, DefaultController));
    }
コード例 #9
0
        public async Task <IActionResult> Delete([FromBody] DeleteProductViewModel model)
        {
            if (model.Id <= 0)
            {
                return(BadRequest());
            }

            var modelo = await _context.Products.FirstOrDefaultAsync(x => x.Id == model.Id);

            modelo.Enabled = false;



            _context.Entry(modelo).State = EntityState.Modified;

            if (modelo == null)
            {
                return(NotFound());
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                //Guardar Exception
                return(BadRequest());
            }

            return(Ok());
        }
コード例 #10
0
        public DeleteProductViewModel GetDeleteSekciqViewModel(int id)
        {
            Sekciq sekciq = this.Context.Sekcii.Find(id);
            DeleteProductViewModel model = Mapper.Map <Sekciq, DeleteProductViewModel>(sekciq);

            return(model);
        }
コード例 #11
0
        public IActionResult Delete(DeleteProductViewModel model)
        {
            var mappedProductFromModel = this.mapper.Map <Product>(model);

            productsService.Delete(mappedProductFromModel);
            productsService.Save();
            return(this.RedirectToAction("Index", "Products"));
        }
コード例 #12
0
        public IActionResult Delete(DeleteProductViewModel vm)
        {
            var mapperProductInModel = _mapper.Map <Product>(vm);

            _product.DeleteProrduct(mapperProductInModel);
            _product.Save();
            return(RedirectToAction(nameof(Index)));
        }
コード例 #13
0
        public IActionResult Remove([FromForm] DeleteProductViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                _productService.DeleteProduct(viewModel.ProductId);
            }

            return(RedirectToRoute("getAllProductsEmpty"));
        }
コード例 #14
0
ファイル: ProductController.cs プロジェクト: blgest/chushka
 public async Task <IActionResult> Delete(DeleteProductViewModel deleteProductViewModel, string id)
 {
     if (this.User.IsInRole("Admin"))
     {
         this.productService.Delete(id);
         return(this.RedirectToAction("Index", "Home"));
     }
     return(this.View());
 }
コード例 #15
0
        public IActionResult DeleteProduct(Product product)
        {
            List <Product> products = _productRepository.GetAllProducts();

            var viewModel = new DeleteProductViewModel {
                Products = products
            };

            return(View(viewModel));
        }
コード例 #16
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            DeleteProductViewModel viewModel = new DeleteProductViewModel();

            viewModel.Product = await _context.Producten.Include(x => x.ProductType).FirstOrDefaultAsync(x => x.ProductID == id);

            _context.Producten.Remove(viewModel.Product);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(IndexManager)));
        }
コード例 #17
0
        public async Task <IActionResult> DeleteProduct(DeleteProductViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var deleteResult = await _productRepository.DeleteProductAsync(model.ProductId);

            if (deleteResult == null)
            {
                return(NotFound());
            }
            return(RedirectToAction(nameof(Products)));
        }
コード例 #18
0
        public async Task <IActionResult> DeleteConfirmed(DeleteProductViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _bll.ProductService.DeleteProductAsync(vm.ProductId);

                if (result == false)
                {
                    return(BadRequest("Error while deleting entry"));
                }
                return(RedirectToAction("Organization", "Dashboard", new { Id = vm.OrganizationId }));
            }

            return(BadRequest());
        }
コード例 #19
0
ファイル: ProductController.cs プロジェクト: blgest/chushka
        public async Task <IActionResult> Delete(string id)
        {
            if (this.User.IsInRole("Admin"))
            {
                var product = productService.Details(id);

                var deleteProductViewModel = new DeleteProductViewModel()
                {
                    Name        = product.Name,
                    Price       = product.Price,
                    Description = product.Description,
                    Type        = product.Type
                };
                return(this.View(deleteProductViewModel));
            }
            return(this.View());
        }
コード例 #20
0
        public ResultViewModel Remove([FromBody] DeleteProductViewModel model)
        {
            var product = _repo.Find(model.Id);

            _repo.Remove(product);

            return(new ResultViewModel
            {
                Success = true,
                Message = "Product deleted",
                Data = new DeleteProductViewModel
                {
                    Id = model.Id,
                    Title = model.Title
                }
            });
        }
コード例 #21
0
    public IActionResult DeleteProduct(Guid?id)
    {
        if (id == null)
        {
            return(RedirectToAction(IndexAction, DefaultController));
        }

        var productToDel = _productRepository.GetOne(id.Value);

        if (productToDel == null)
        {
            return(View("ProductNotFound", id.Value));
        }

        var deleteProductViewModel = new DeleteProductViewModel {
            Product = productToDel
        };

        return(View(deleteProductViewModel));
    }
コード例 #22
0
        // GET: Product/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DeleteProductViewModel viewModel = new DeleteProductViewModel();

            viewModel.Product = await _context.Producten
                                .Include(p => p.ProductType)
                                .FirstOrDefaultAsync(m => m.ProductID == id);

            if (viewModel.Product == null)
            {
                return(NotFound());
            }

            return(View(viewModel));
        }
コード例 #23
0
        public IActionResult DeleteProduct([Required] int productId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var product = _productRepository.Products.Where(p => p.ProductId == productId).SingleOrDefault();

            if (product == null)
            {
                return(NotFound());
            }
            var model = new DeleteProductViewModel
            {
                ProductId   = product.ProductId,
                ProductName = product.ProductName
            };

            return(View(model));
        }
コード例 #24
0
        public async Task <IActionResult> DeleteProduct(int deleteIndex, string returnUrl = null)
        {
            var model = new DeleteProductViewModel()
            {
                IndexChanges = deleteIndex,
            };

            var user = await _userManager.GetUserAsync(HttpContext?.User);

            model.Products = await GetProductsOfSuppliers(user);

            if (ModelState.IsValid &&
                model.Products != null &&
                model.IndexChanges >= 0 && model.IndexChanges < model.Products.Count())
            {
                var changeGood = model.Products.ElementAt(model.IndexChanges);
                await _streinger.RemoveGood(changeGood as Good);
            }

            return(RedirectToAction("СhangeProduct"));
        }
コード例 #25
0
        public void Gallery_Product_Delete()
        {
            var urlapi = new UrlApi()
            {
                Url = "https://localhost:44397/api/v1/"
            };
            var client = new WebClient();
            var option = new Mock <IOptions <UrlApi> >();

            option.Setup(c => c.Value).Returns(urlapi);
            var getapi        = new GetProductApi(client, option.Object);
            var result        = client.DownloadString(option.Object.Value.Url + "product/1/1");
            var getAllProduct = JsonConvert.DeserializeObject <GetAllProductViewModel>(result);
            var product       = getAllProduct.Products.LastOrDefault();
            var model         = new DeleteProductViewModel {
                ProductRequest = new FindProductViewModel {
                    Customer = product.Customer, SiteName = product.SiteName, SiteUrl = product.SiteUrl
                }
            };

            result = getapi.Delete(model);
            Assert.Equal("Deleted", result);
        }
コード例 #26
0
        public async Task <IActionResult> Delete(int id)
        {
            var product = await _dbContext.Products
                          .Include(u => u.ApplicationUser)
                          .Where(p => p.Id == id)
                          .FirstOrDefaultAsync();

            if (product == null)
            {
                return(new NotFoundResult());
            }


            var authorizationResult = await _authorizationService
                                      .AuthorizeAsync(User, product, CRUD.Delete);

            if (authorizationResult.Succeeded)
            {
                DeleteProductViewModel model = new DeleteProductViewModel
                {
                    Id          = product.Id,
                    Name        = product.Name,
                    Description = product.Description,
                    Price       = product.Price
                };

                return(View(model));
            }
            else if (User.Identity.IsAuthenticated)
            {
                return(new ForbidResult());
            }
            else
            {
                return(new ChallengeResult());
            }
        }
コード例 #27
0
        public async Task <IActionResult> Delete(DeleteProductViewModel model)
        {
            var product = await _dbContext.Products
                          .Include(u => u.ApplicationUser)
                          .Where(p => p.Id == model.Id)
                          .FirstOrDefaultAsync();

            if (product == null)
            {
                return(new NotFoundResult());
            }


            var authorizationResult = await _authorizationService
                                      .AuthorizeAsync(User, product, CRUD.Delete);

            if (authorizationResult.Succeeded)
            {
                /* Presist the Delete
                 * ------------------
                 * 1- Remove the product from _dbContext
                 * 2- SaveChanges()
                 */

                _logger.LogInformation($"Product: {product.ToString()}, has been Deleted.");
                return(RedirectToAction("Index", "Product"));
            }
            else if (User.Identity.IsAuthenticated)
            {
                return(new ForbidResult());
            }
            else
            {
                return(new ChallengeResult());
            }
        }
コード例 #28
0
 public IActionResult DeleteProduct(DeleteProductViewModel viewModel)
 {
     _service.DeleteProduct(viewModel.idToDelete);
     return(View());
 }
コード例 #29
0
        public ActionResult DeleteSpalni(int id)
        {
            DeleteProductViewModel model = this.service.GetDeleteSpalnqViewModel(id);

            return(this.View(model));
        }
コード例 #30
0
        public ActionResult DeletePortmanta(int id)
        {
            DeleteProductViewModel model = this.service.GetDeletePortmantoViewModel(id);

            return(this.View(model));
        }