/***************DELETE********************/ public async Task <IActionResult> Delete(int?id) { try { if (id == null) { throw new Exception(); } var item = await _premiumRepository.GetByIdWithIncludesAsync(id.Value); if (item == null) { throw new Exception(); } var result = await _premiumRepository.DeleteAsync(item); if (!result) { throw new Exception("Failed to delete."); } var notify = _notificationHelper.DeleteOldByIdAsync(item.OfferIdGuid); return(RedirectToAction(nameof(PremiumIndex))); } catch (Exception) { return(new NotFoundViewResult("_Error404")); } }
public async Task <IActionResult> DeleteOffer(int id) { try { var offer = await _premiumRepository.GetByIdAsync(id); if (offer == null) { throw new Exception(); } var result = await _premiumRepository.DeleteAsync(offer); return(RedirectToAction("OffersIndex")); } catch (Exception) { return(new NotFoundViewResult("_404Error")); } }