public DeleteProductViewModel GetDeleteDetskaViewModel(int id) { Detska detska = this.Context.Detski.Find(id); DeleteProductViewModel model = Mapper.Map <Detska, DeleteProductViewModel>(detska); return(model); }
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)); }
public DeleteProductViewModel GetDeleteSpalnqViewModel(int id) { Spalnq spalnq = this.Context.Spalni.Find(id); DeleteProductViewModel model = Mapper.Map <Spalnq, DeleteProductViewModel>(spalnq); return(model); }
public DeleteProductViewModel GetDeletePortmantoViewModel(int id) { Portmanto portmanto = this.Context.Portmanta.Find(id); DeleteProductViewModel model = Mapper.Map <Portmanto, DeleteProductViewModel>(portmanto); return(model); }
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)); }
public DeleteProductViewModel GetDeleteKuhnqViewModel(int id) { Kuhnq kuhnq = this.Context.Kuhni.Find(id); DeleteProductViewModel model = Mapper.Map <Kuhnq, DeleteProductViewModel>(kuhnq); return(model); }
public DeleteProductViewModel GetDeleteMasaViewModel(int id) { Masa masa = this.Context.Masi.Find(id); DeleteProductViewModel model = Mapper.Map <Masa, DeleteProductViewModel>(masa); return(model); }
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)); }
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()); }
public DeleteProductViewModel GetDeleteSekciqViewModel(int id) { Sekciq sekciq = this.Context.Sekcii.Find(id); DeleteProductViewModel model = Mapper.Map <Sekciq, DeleteProductViewModel>(sekciq); return(model); }
public IActionResult Delete(DeleteProductViewModel model) { var mappedProductFromModel = this.mapper.Map <Product>(model); productsService.Delete(mappedProductFromModel); productsService.Save(); return(this.RedirectToAction("Index", "Products")); }
public IActionResult Delete(DeleteProductViewModel vm) { var mapperProductInModel = _mapper.Map <Product>(vm); _product.DeleteProrduct(mapperProductInModel); _product.Save(); return(RedirectToAction(nameof(Index))); }
public IActionResult Remove([FromForm] DeleteProductViewModel viewModel) { if (ModelState.IsValid) { _productService.DeleteProduct(viewModel.ProductId); } return(RedirectToRoute("getAllProductsEmpty")); }
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()); }
public IActionResult DeleteProduct(Product product) { List <Product> products = _productRepository.GetAllProducts(); var viewModel = new DeleteProductViewModel { Products = products }; return(View(viewModel)); }
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))); }
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))); }
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()); }
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()); }
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 } }); }
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)); }
// 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)); }
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)); }
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")); }
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); }
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()); } }
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()); } }
public IActionResult DeleteProduct(DeleteProductViewModel viewModel) { _service.DeleteProduct(viewModel.idToDelete); return(View()); }
public ActionResult DeleteSpalni(int id) { DeleteProductViewModel model = this.service.GetDeleteSpalnqViewModel(id); return(this.View(model)); }
public ActionResult DeletePortmanta(int id) { DeleteProductViewModel model = this.service.GetDeletePortmantoViewModel(id); return(this.View(model)); }