Example #1
0
        public CustomerDashboardObj LoanStaging()
        {
            List <stagingObj> LoanStagingCount = new List <stagingObj>();
            List <string>     label            = new List <string>();
            List <decimal>    sum = new List <decimal>();
            var count             = _dataContext.credit_impairment_final
                                    .Where(o => o.Stage != null)
                                    .Select(x => new { x.Stage, x.EAD }).GroupBy(y => new { y.Stage }, (key, group) => new stagingObj
            {
                stage = key.Stage,
                count = (int)group.Sum(k => k.EAD)
            }).ToList();

            LoanStagingCount.AddRange(count);

            foreach (var app in LoanStagingCount)
            {
                label.Add(app.stage);
                //var new_count = app.count.ToString("#,##0.00");
                sum.Add(app.count);
            }

            var performanceMatrics = new CustomerDashboardObj
            {
                Labels   = label.ToArray(),
                Datasets = new List <CustomerDatasetObj>
                {
                    new CustomerDatasetObj
                    {
                        Label           = "Loan Staging",
                        BackgroundColor = "#42A5F5",
                        BorderColor     = "1E88E5",
                        Data            = sum.ToArray(),
                    },
                }
            };

            return(performanceMatrics);
        }
Example #2
0
        public CustomerDashboardObj GetCustomerTransactionSummary(string accountNumber)
        {
            var inflow = _dataContext.fin_customertransaction
                         .Where(o => o.TransactionDate.Value.Year == DateTime.Now.Year && o.AccountNumber == accountNumber && o.TransactionType == "Credit")
                         .Select(x => new { x.TransactionDate, x.Amount }).GroupBy(y => new { y.TransactionDate.Value.Month }, (key, group) => new
            {
                MonthNumber = key.Month,
                Count       = group.Count(),
                Sum         = group.Sum(k => k.Amount)
            }).ToList();

            var outflow = _dataContext.fin_customertransaction
                          .Where(o => o.TransactionDate.Value.Year == DateTime.Now.Year && o.AccountNumber == accountNumber && o.TransactionType == "Debit")
                          .Select(x => new { x.TransactionDate, x.Amount }).GroupBy(y => new { y.TransactionDate.Value.Month }, (key, group) => new
            {
                MonthNumber = key.Month,
                Count       = group.Count(),
                Sum         = group.Sum(k => k.Amount)
            }).ToList();

            List <decimal> inflowCount  = new List <decimal>();
            List <decimal> outflowCount = new List <decimal>();

            foreach (var app in MonthNumberPair)
            {
                var     result = inflow.FirstOrDefault(x => x.MonthNumber == app.Key);
                decimal count  = 0;

                if (result != null)
                {
                    count = result.Sum ?? 0;
                }

                inflowCount.Add(count);
            }

            foreach (var app in MonthNumberPair)
            {
                var     result = outflow.FirstOrDefault(x => x.MonthNumber == app.Key);
                decimal count  = 0;

                if (result != null)
                {
                    count = result.Sum ?? 0;
                }

                outflowCount.Add(count);
            }


            var performanceMatrics = new CustomerDashboardObj
            {
                Labels   = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" },
                Datasets = new List <CustomerDatasetObj>
                {
                    new CustomerDatasetObj
                    {
                        Label           = "Inflow",
                        BackgroundColor = "#42A5F5",
                        BorderColor     = "1E88E5",
                        Data            = inflowCount.ToArray(),
                    },
                    new CustomerDatasetObj
                    {
                        Label           = "Outflow",
                        BackgroundColor = "#9CCC65",
                        BorderColor     = "7CB342",
                        Data            = outflowCount.ToArray(),
                    }
                }
            };

            return(performanceMatrics);
        }