Пример #1
0
        public IEnumerable <Debts> Get(string yr, string client)
        {
            var paid = new List <Debts>();

            using (pdInvoiceEntities db = new pdInvoiceEntities())
            {
                var m         = Enumerable.Range(1, 12);
                var months    = db.Nairas.Select(c => c.DateSubmitted.Value.Month).Distinct().AsEnumerable();
                var year      = DateTime.Now.Year;
                var queryYear = int.Parse(yr);
                var data      = db.Nairas.Where(c => c.DateSubmitted.Value.Year == queryYear && c.ClientName.Equals(client)).ToList();
                foreach (var b in m)
                {
                    var ninflow = data.Where(c => c.DateSubmitted.Value.Month == b).Sum(c => c.AmountPaid);
                    var outflow = data.Where(c => c.DateSubmitted.Value.Month == b).Sum(c => c.Outstanding);
                    var p       = new Debts
                    {
                        //  Dtype = "Paid",
                        //Flow = Convert.ToDecimal(ninflow),
                        Month  = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(b),
                        Paid   = Convert.ToDecimal(ninflow),
                        Unpaid = outflow
                    };
                    paid.Add(p);
                }

                return(paid);
            }
        }
Пример #2
0
        public IEnumerable <Debts> Get()
        {
            var paid = new List <Debts>();

            using (pdInvoiceEntities db = new pdInvoiceEntities())
            {
                var m = Enumerable.Range(1, 12);
                //  var months = db.Nairas.Select(c => c.Month).Distinct().AsEnumerable();
                var year = DateTime.Now.Year;
                var data = db.Dollars.Where(c => c.DateSubmitted.Value.Year == year).ToList();
                foreach (var b in m)
                {
                    var ninflow = data.Where(c => c.DateSubmitted.Value.Month == b).Sum(c => c.AmountPaid);
                    var outflow = data.Where(c => c.DateSubmitted.Value.Month == b).Sum(c => c.Outstanding);
                    var p       = new Debts
                    {
                        Month  = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(b),
                        Paid   = Convert.ToDecimal(ninflow),
                        Unpaid = outflow
                    };
                    paid.Add(p);
                }

                return(paid);
            }
        }