public async Task <ActionResult> Edit(Guid id, EditPricingViewModel 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 priceUpdateRequest = new UpdatePricingRequest { Id = request.Id, Price = request.Price, ProductId = request.ProuctId }; var result = await _pricingService.Update(id, priceUpdateRequest); if (!result.Success) { Alert($"Error: {result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } Alert($"Category 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: Pricing/Edit/5 public async Task <ActionResult> Edit(Guid id) { var price = new EditPricingViewModel(); try { var result = await _pricingService.FindById(id); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(price)); } price.Id = result.Data.Id; price.Tier = result.Data.Tier.Name; price.Product = result.Data.Product.Name; return(View(price)); } catch (Exception ex) { Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(price)); } }