public async Task <IActionResult> DeleteArticleFromCart(long articleId) { var cart = await GetCurrentUserCart(); var list = new List <DTOArticle>(); foreach (var elem in cart) { var curr = await _articleRepo.GetById(elem.ArticleId); if (curr.Id != articleId) { list.Add(curr); } } var toDelete = await _cartRepo.GetCartItemByArticleId(articleId); var res = await _cartRepo.Delete(toDelete.Id); if (res == false) { return(View("Failed")); } ViewData["cartlist"] = list; ViewData["PageTitle"] = "cart details"; return(View("ShowCart")); }
public HttpResponseMessage DeleteCart(int cartId) { bool result = cartRepo.Delete(cartId); return(CheckResult(result)); }