public async Task <ActionResult> Edit(Guid id, EditTierViewModel 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 tierUpdateRequest = new UpdateTierRequest { Id = request.Id, Name = request.Name, Description = request.Description }; var result = await _tierService.Update(id, tierUpdateRequest); if (!result.Success) { Alert($"Error: {result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } Alert($"Tier 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()); } }
public async Task <ServiceResponse <Tier> > Update(Guid id, UpdateTierRequest request) { try { var result = await _baseRepository.GetById(id); if (result == null) { return(new ServiceResponse <Tier>($"The requested Tier could not be found")); } result.Name = request.Name; result.Description = request.Description; result.LastUpdated = DateTime.Now; await _baseRepository.Update(id, result); return(new ServiceResponse <Tier>(result)); } catch (Exception ex) { return(new ServiceResponse <Tier>($"An Error Occured While Updating The Tier. {ex.Message}")); } }