public async Task <ActionResult> Delete(ProductItemViewModel productItem) { try { // TODO: Add delete logic here var combos = await _comboProductService.GetAllByProductItemIdAsync(productItem.Id); foreach (var combo in combos) { if (await _comboService.GetComboMealAsync(combo.ComboId) != null) { await _comboService.DeleteComboMealAsync(combo.ComboId); } } var deletedProduct = await _productItemService.DeleteProductItemAsync(productItem.Id); if (deletedProduct != null) { TempData["Message"] = "Product deleted successfully"; return(RedirectToAction(nameof(Index))); } return(View()); } catch { return(View()); } }
// GET: ComboMeal/Details/5 public async Task <ActionResult> Details(int id) { var combos = _mapper.Map <CombosViewModel>(await _comboService.GetComboMealAsync(id)); return(View(combos)); }