public async Task DeleteProduct_WithValidProductId_ReturnsOk() { A.CallTo(() => _productsService.DeleteProduct(1)).Returns(true); ActionResult returns = await _productController.DeleteProduct(1); A.CallTo(() => _productsService.DeleteProduct(A <int> ._)).MustHaveHappened(); Assert.AreEqual(returns.GetType(), typeof(OkResult)); }
public ActionResult <int> DeleteProduct(int id) { Thread.Sleep(_delay); _service.DeleteProduct(id); //_logger.LogInformation("products", _products); return(id); }
public IActionResult Delete() { if (!this.AdminAuthorization()) { return(RedirectToAction("/")); } var product = GetProductById(); var viewModel = service.DeleteProduct(product); this.Model["ProductDelete"] = viewModel; return(this.View()); }
public IActionResult Delete(Guid id) { _prodService.DeleteProduct(id); TempData["feedback"] = "Product was deleted successfully"; //ViewData should be changed to TempData return(RedirectToAction("Index")); }
public async Task <ActionResult <bool> > DeleteProduct(int id) { if (!await _productsService.ProductExists(id)) { return(NotFound()); } bool isSuccess = await _productsService.DeleteProduct(id); return(isSuccess); }
public async Task <ActionResult> DeleteProduct(int id) { bool wasDeleted = await _productsService.DeleteProduct(id); if (wasDeleted) { return(Ok()); } return(NotFound()); }
public void Delete(Guid id) { try { _productsService.DeleteProduct(id); } catch (Exception) { var response = HttpResponseFactory.ConstructResponse(HttpStatusCode.BadRequest, "Delete failed, please try again."); throw new HttpResponseException(response); } }
public IHttpActionResult DeleteProduct(int id) { int result = _productsService.DeleteProduct(id); if (result == 1) { return(StatusCode(HttpStatusCode.NoContent)); } return(NotFound()); }
public IActionResult Delete(int id) { try { _productsService.DeleteProduct(id); return(this.CreateSuccesfullResponse()); } catch (Exception ex) { return(this.CreateErrorResponse(ex)); } }
public IActionResult Delete(Guid id) { try { _productsService.DeleteProduct(id); TempData["feedback"] = "Product was deleted successfully"; //change wherever we are using viewdata to use tempdata return(RedirectToAction("Index")); }catch (Exception) { return(RedirectToAction("Error", "home")); } }
public ActionResult DeleteProduct(Guid id) { try { _productsService.DeleteProduct(id); return(Ok(true)); } catch (Exception ex) { throw ex; } }
public IHttpActionResult Delete(int id) { if (productsService.DeleteProduct(id)) { productsService.SaveChanges(); return(Ok()); } else { return(NotFound()); } }
public async Task <IActionResult> DeleteProduct(int id) { try { var results = _productsService.DeleteProduct(id); return(new JsonResult(results)); } catch (NotFoundException ex) { return(BadRequest(ex.Message)); } }
public IActionResult Delete(Guid id, string cate) { try { _productsService.DeleteProduct(id); TempData["feedback"] = "Product was deleted successfully"; _logger.LogInformation("Product was deleted successfully"); return(RedirectToAction("Index", new { category = cate })); } catch (Exception ex) { return(RedirectToAction("Error", "Home")); } }
public async Task <IActionResult> DeleteProduct(int SKU) { try { await _productsService.DeleteProduct(SKU); return(Ok()); } catch (Exception e) { return(StatusCode(500, e)); } }
public async Task <IActionResult> Delete(int id) { try { await _productsService.DeleteProduct(id); return(Ok("Product record deleted successfully")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public HttpResponse Delete(int id) //? // After deleting or creating a Product, redirect to the Home Page { if (!IsUserLoggedIn()) { return(this.Redirect("/Users/Login")); } service.DeleteProduct(id); return(this.Redirect("/")); }
public async Task <IActionResult> Delete(int id) { try { await _service.DeleteProduct(id); return(Ok()); } catch (EntityNotFoundException) { return(NotFound(id)); } }
public async Task <ActionResult> DeleteProduct(int id) { var completed = await productsService.DeleteProduct(id); if (!completed) { return(NotFound()); } else { return(Ok()); } }
public async Task <IActionResult> Delete(int id, IFormCollection collection) { try { await _productsService.DeleteProduct(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <IActionResult> DeleteProduct(string id) { try { await _productsService.DeleteProduct(id); return(Ok(id)); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(StatusCode(StatusCodes.Status500InternalServerError, ex)); } }
public IActionResult Delete(Guid id) { try { _productsService.DeleteProduct(id); TempData["feedback"] = "Product was deleted"; } catch (Exception ex) { TempData["warning"] = "Product was not deleted"; } return(RedirectToAction("Index")); }
public IActionResult DeleteProduct(int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (_productsService.DeleteProduct(id)) { return(new EmptyResult()); } return(BadRequest()); }
public IActionResult Delete(Guid id) { try { ViewData["feedback"] = "Product was deleted"; _productsService.DeleteProduct(id); } catch (Exception ex) { //log your error ViewData["warning"] = "Product was not deleted";//Change from viewData to tempData } return(RedirectToAction("Index")); }
public IActionResult Delete(Guid id) { try { _productsService.DeleteProduct(id); TempData["feedback"] = "Product was deleted"; } catch (Exception) { //log your error TempData["Error"] = "Product was not deleted!! "; return(RedirectToAction("Error", "Home")); } return(RedirectToAction("Index")); }
public IActionResult Delete(Guid id) { try { _productsService.DeleteProduct(id); TempData["feedback"] = "Product was deleted"; _productsLogger.LogInformation("Product Deleted"); } catch (Exception ex) { TempData["warning"] = "Product was not deleted"; //Change from ViewData to TempData _productsLogger.LogError(ex.Message); } return(RedirectToAction("Index")); }
public IActionResult Delete(Guid id) { try { _productsService.DeleteProduct(id); TempData["feedback"] = "Product was deleted successfully"; _logger.LogInformation("Successfully Deleted Product " + id); return(RedirectToAction("Index")); } catch (Exception ex) { TempData["danger"] = "Something went wrong"; _logger.LogError(ex.Message); return(RedirectToAction("Index")); } }
public IActionResult Delete(Guid id) { try { _productsService.DeleteProduct(id); TempData["feedback"] = "Product was deleted"; } catch (Exception ex) { //Log your error TempData["warning"] = "Product was not deleted"; _logger.LogError(ex.Message); return(RedirectToAction("Error", "Home")); } return(RedirectToAction("Index")); }
public IActionResult DeleteProduct(long foodId, long productId)//ActionResult<bool> { try { var result = _productService.DeleteProduct(foodId, productId); return(Ok(result)); } catch (NotFoundItemException ex) { return(BadRequest(ex.Message)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Something unexpected happened.")); } }
public async Task <IActionResult> Delete(int id, CancellationToken cancellationToken) { try { await _productsService.DeleteProduct(id, cancellationToken); } catch (ArgumentException e) { return(NotFound()); } catch (Exception e) { return(BadRequest(e.Message)); } return(NoContent()); }