public void DeleteProductHandler_valid() { var repository = new FakeProductRepository(); var handler = new ProductHandler(repository); string id = repository.GetAll().FirstOrDefault().Id; var result = handler.Delete(id); Assert.True(result.Success, result.Message); }
public void DeleteProductHandler_NotExists_Invalid() { var repository = new FakeProductRepository(); var handler = new ProductHandler(repository); string id = Guid.NewGuid().ToString(); var result = handler.Delete(id); Assert.False(result.Success, result.Message); }
public void Delete_ProductExists_ReturnTrue() { // Arrange ProductProvider productProvider = new ProductProvider(); var allProducts = productProvider.GetAll().OrderByDescending(p => p.Id); Product lastProduct = allProducts.FirstOrDefault() ?? new Product(); ProductHandler productHandler = new ProductHandler(); // Act bool result = productHandler.Delete(lastProduct.Id); var deletedProduct = productProvider.GetById(lastProduct.Id); // Assert Assert.IsTrue(result); Assert.IsNull(deletedProduct); }
private static void OpenProductHandlerMenu() { bool shouldBeOpen = true; while (shouldBeOpen) { Console.Clear(); PrintProductHandlerMenu(); string userInput = Console.ReadLine(); if (userInput == "0") { shouldBeOpen = false; } else if (userInput == "1") { ProductHandler.ListAll(); ReturnToMenu(); } else if (userInput == "2") { ProductHandler.Create(); ReturnToMenu(); } else if (userInput == "3") { ProductHandler.Delete(); ReturnToMenu(); } else if (userInput == "4") { ProductHandler.Edit(); ReturnToMenu(); } else { PrintInvalidChoice(); } } }
// DELETE BY GETTING PARAMETER FROM URL private void deleteValue() { if (Request.QueryString["productId"] != null) { ProductId = Int32.Parse(Request.QueryString["productId"]); Product p = ProductHandler.GetById(ProductId); if (System.IO.File.Exists(Server.MapPath("~/") + p.ProductImage)) { System.IO.File.Delete(Server.MapPath("~/") + p.ProductImage); } ReviewHandler.Delete(ProductId); ProductHandler.Delete(ProductId); Response.Redirect("Home.aspx"); } else if (Request.QueryString["userId"] != null) { UserId = Int32.Parse(Request.QueryString["userId"]); User u = UserHandler.GetById(UserId); if (System.IO.File.Exists(Server.MapPath("~/") + u.UserProfilePicture)) { System.IO.File.Delete(Server.MapPath("~/") + u.UserProfilePicture); } UserHandler.Delete(UserId); Response.Redirect("Member.aspx"); } else if (Request.QueryString["review"] != null) { ReviewId = Int32.Parse(Request.QueryString["review"]); //Review r = ReviewHandler.GetById(ReviewId); ReviewHandler.Delete(ReviewId); //Response.Redirect("ProductShowCaseDetail.aspx?productId=" + ProductId); Response.Redirect("Home.aspx"); } }
public ICommandResult Delete(int sku) { var result = (CommandResult)_handler.Delete(sku); return(result); }
public ActionResult Delete(int id) { productHandler.Delete(id); return(RedirectToAction("Index")); }
public bool Delete(string code) { return(handler.Delete(code)); }