public async Task <ActionResult> Edit(Guid id, EditCertainValueCertainProductDiscountViewModel request) { if (!ModelState.IsValid) { Alert("Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } if (!id.Equals(request.Id)) { Alert("Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } try { var cvDiscountUpdateRequest = new UpdateCertainValueCertainProductDiscountRequest { Id = request.Id, Name = request.Name, Description = request.Description }; var result = await _certainValueCertainProductDiscountService.Update(id, cvDiscountUpdateRequest); if (!result.Success) { Alert($"Error: {result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } Alert($"Discount Updated 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()); } }
// GET: CertainValueCertainProductDiscount/Edit/5 public async Task <ActionResult> Edit(Guid id) { var cvDiscount = new EditCertainValueCertainProductDiscountViewModel(); try { var result = await _certainValueCertainProductDiscountService.FindById(id); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(cvDiscount)); } cvDiscount.Id = result.Data.Id; cvDiscount.Name = result.Data.Name; cvDiscount.Description = result.Data.Description; return(View(cvDiscount)); } catch (Exception ex) { Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(cvDiscount)); } }