public IActionResult GetWorkloadAnalyses(GetWorkloadAnalysesRequest request) { GetWorkloadAnalysesReponse result = new GetWorkloadAnalysesReponse(); if (request != null && request.Filter != null) { HandleException(() => { var repository = DALRepositories.GetWorkloadAnalysesRepository(); var analyses = repository.GetForDatabase(request.DatabaseID, request.Filter.DateFrom, request.Filter.DateTo); result.Data = new List <WorkloadAnalysisData>(); foreach (var a in analyses) { result.Data.Add(Converter.Convert(a)); } result.IsSuccess = result.Data != null; }, ex => result.ErrorMessage = ex.Message); } return(Json(result)); }
public IActionResult CreateWorkloadAnalysis(CreateWorkloadAnalysisRequest request) { BaseOperationResponse result = new BaseOperationResponse() { IsSuccess = false }; (bool isValid, string errorMessage) = WorkloadAnalysisValidator.Validate(request); if (!isValid) { result.ErrorMessage = errorMessage; } else { HandleException(() => { var workloadAnalysis = Converter.CreateWorkloadAnalysis(request); var repository = DALRepositories.GetWorkloadAnalysesRepository(); repository.Create(workloadAnalysis); result.IsSuccess = true; }, ex => result.ErrorMessage = ex.Message); } return(Json(result)); }