public async Task <IActionResult> AddArticle(int articleID, string email = null) { if (email == null) { email = HttpContext.User.Identity.Name; } try { DTOCart cart = new DTOCart(); var user = _userRepo.GetUserByEmail(email); var test = await _cartRepo.UserCartAlreadyContains(articleID, user.Id); if (test == false) { cart.ArticleId = articleID; cart.BuyerId = user.Id; cart.Quantity = 1; cart.Article = null; cart.Buyer = null; var result = await _cartRepo.Insert(cart); if (result != null) { return(View()); } } } catch (Exception ex) { _logger.LogError("CONTROLLER USER -- AddArticle() -- Error : ", ex); return(BadRequest()); } return(RedirectToAction("Index", "Article")); }