// GET: PromotionDiscounts/Details/5 public async Task <ActionResult> Details(Guid id) { var promotionDiscount = new PromotionDiscountDetailsViewModel(); try { var result = await _promotionDiscountService.FindById(id); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(promotionDiscount)); } promotionDiscount.Code = result.Data.Code; promotionDiscount.Id = result.Data.Id; promotionDiscount.ProductId = result.Data.ProductId; promotionDiscount.Description = result.Data.Description; promotionDiscount.DateCreated = result.Data.CreatedAt; promotionDiscount.DateLastUpdated = result.Data.LastUpdated; return(View(promotionDiscount)); } catch (Exception ex) { Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(promotionDiscount)); } }
public async Task <ActionResult> Delete(Guid id, PromotionDiscountDetailsViewModel request) { if (!ModelState.IsValid) { Alert("Bad Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } if (id == null) { Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } try { var result = await _promotionDiscountService.Delete(id); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } Alert($"Discount Deleted Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Index))); } catch { Alert($"Error Occurred While processing the request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } }