public async Task <ServiceResponse <Pricing> > Update(Guid id, UpdatePricingRequest request) { try { var result = await _baseRepository.GetById(id); if (result == null) { return(new ServiceResponse <Pricing>($"The requested Pricing could not be found")); } result.Price = request.Price; result.ProductId = request.ProductId; result.TierId = request.TierId; result.LastUpdated = DateTime.Now; await _baseRepository.Update(id, result); return(new ServiceResponse <Pricing>(result)); } catch (Exception ex) { return(new ServiceResponse <Pricing>($"An Error Occured While Updating The Pricing. {ex.Message}")); } }
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()); } }