public virtual ActionResult GetGraphMonthlyProyections(Models.GraphViewModel graphData) { var ajaxResult = new Dictionary <string, string>(); try { var newGraph = new MW.Domain.Models.Disbursement.GraphViewModel { ActualAgreed = graphData.ActualAgreed, CurrentProjectionMonth = graphData.CurrentProjectionMonth, ExchangeRate = graphData.ExchangeRate, ExchangeRates = graphData.ExchangeRates != null ? graphData.ExchangeRates.Where(x => x != null).ToList() : new List <ExchangeRateModel>(), IsExecution = graphData.IsExecution, LoanNumber = graphData.LoanNumber, LoanNumbers = graphData.LoanNumbers, ProjectedYears = graphData.ProjectedYears.ConvertToModel() }; var result = _disbursementService.SetMonthlyProjections2(newGraph); ajaxResult[DisbursementValues.ACTION] = DisbursementValues.CALL_FUNCTION_PARAMETERED; ajaxResult[DisbursementValues.CALL_FUNCTION_FN] = DisbursementValues.DISBURSEMENT_SHOW_MONTHLYGRAPH; ajaxResult[DisbursementValues.CALL_FUNCTION_PARAMETERS] = string.Format( DisbursementValues.STRING_FORMAT, new JavaScriptSerializer().Serialize(result)); } catch (Exception e) { ajaxResult[DisbursementValues.ACTION] = DisbursementValues.SHOW_ERROR; ajaxResult[DisbursementValues.ERROR_TEXT] = e.Message; } return(Content(new JavaScriptSerializer().Serialize(ajaxResult))); }
public virtual ActionResult GetGraphMonthlyProyections(Models.GraphViewModel graphData) { var ajaxResult = new Dictionary <string, string>(); try { var result = new Dictionary <string, List <decimal?> >(); int currentYear = DateTime.Now.Year; var projectedMonths = graphData.ProjectedYears.ConvertToModel() .Where(x => x.Year == currentYear).SelectMany(x => x.ProjectedMonths).ToList(); projectedMonths.ForEach(x => { if (x.ProjectedAmount == decimal.MinValue) { x.ProjectedAmount = DisbursementValues.ZERO_NUMB; } else { x.ProjectedAmount *= graphData.ExchangeRate; } }); var currentProjection = graphData.CurrentProjectionMonth; var response = _disbursementService.ConvertEdwDataToActualProjectionModel( graphData.ActualAgreed, graphData.ExchangeRate); result[DisbursementValues.AGREED_PROJECTIONS] = new List <decimal?>(); result[DisbursementValues.CURRENT_PROJECTIONS] = new List <decimal?>(); result[DisbursementValues.ACTUAL_DISBURSEMENTS] = new List <decimal?>(); for (int i = 1; i <= 12; i++) { result[DisbursementValues.AGREED_PROJECTIONS].Add( response.Where(x => x.ACCEOM_DT.Month == i && x.ACCEOM_DT.Year == currentYear && x.LOAN_NUM.Equals(graphData.LoanNumber)) .Sum(x => x.AGREED_PROJ_AMNT) / DisbursementValues.ONE_THOUSAND_NUMB); result[DisbursementValues.CURRENT_PROJECTIONS].Add( projectedMonths.Where(y => y.Month == i).Sum(x => x.ProjectedAmount)); result[DisbursementValues.ACTUAL_DISBURSEMENTS].Add( response.Where(x => x.ACCEOM_DT.Month == i && x.ACCEOM_DT.Year == currentYear && x.LOAN_NUM.Equals(graphData.LoanNumber)) .Sum(x => x.DISB_AMNT_USEQ) / DisbursementValues.ONE_THOUSAND_NUMB); } ajaxResult[DisbursementValues.ACTION] = DisbursementValues.CALL_FUNCTION_PARAMETERED; ajaxResult[DisbursementValues.CALL_FUNCTION_FN] = DisbursementValues.DISBURSEMENT_SHOW_MONTHLYGRAPH; ajaxResult[DisbursementValues.CALL_FUNCTION_PARAMETERS] = string.Format( DisbursementValues.STRING_FORMAT, new JavaScriptSerializer().Serialize(result)); } catch (Exception e) { ajaxResult[DisbursementValues.ACTION] = DisbursementValues.SHOW_ERROR; ajaxResult[DisbursementValues.ERROR_TEXT] = e.Message; } return(Content(new JavaScriptSerializer().Serialize(ajaxResult))); }