public async Task <IActionResult> Delete(string id) { var giftCard = await _giftCardService.GetGiftCardById(id); if (giftCard == null) { //No gift card found with the specified id return(RedirectToAction("List")); } if (giftCard.GiftCardUsageHistory.Any()) { ModelState.AddModelError("", _localizationService.GetResource("Admin.GiftCards.PreventDeleted")); } if (ModelState.IsValid) { await _giftCardViewModelService.DeleteGiftCard(giftCard); SuccessNotification(_localizationService.GetResource("Admin.GiftCards.Deleted")); return(RedirectToAction("List")); } ErrorNotification(ModelState); return(RedirectToAction("Edit", new { id = giftCard.Id })); }
public IActionResult Delete(string id) { var giftCard = _giftCardService.GetGiftCardById(id); if (giftCard == null) { //No gift card found with the specified id return(RedirectToAction("List")); } if (ModelState.IsValid) { _giftCardViewModelService.DeleteGiftCard(giftCard); SuccessNotification(_localizationService.GetResource("Admin.GiftCards.Deleted")); return(RedirectToAction("List")); } ErrorNotification(ModelState); return(RedirectToAction("Edit", new { id = giftCard.Id })); }