// GET: ProductDiscount/Details/5 public async Task <ActionResult> Details(Guid id) { var productDiscount = new ProductDiscountDetailsViewModel(); try { var result = await _productDiscountService.FindById(id); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(productDiscount)); } productDiscount.CatalogueName = result.Data.CatalogueName; productDiscount.Id = result.Data.Id; productDiscount.Name = result.Data.Name; productDiscount.CategoryName = result.Data.CategoryName; productDiscount.BrandName = result.Data.BrandName; productDiscount.PackagingName = result.Data.PackagingName; productDiscount.ProductName = result.Data.ProductName; productDiscount.EffectiveDate = result.Data.EffectiveDate; productDiscount.EndDate = result.Data.EndDate; productDiscount.DateCreated = result.Data.CreatedAt; productDiscount.DateLastUpdated = result.Data.LastUpdated; return(View(productDiscount)); } catch (Exception ex) { Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(productDiscount)); } }
public async Task <ActionResult> Delete(Guid id, ProductDiscountDetailsViewModel 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 _productDiscountService.Delete(id); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } Alert($"Product 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()); } }