Пример #1
0
        public List <ReportData> GetReportTransactions(DateTime fromDate, DateTime toDate, string state)
        {
            List <TransactionModel> reportData = null;

            if (state == "All")
            {
                reportData = new TransactionService().RetrieveTransactionByCycle(null).Where(Tra => Tra.EffectiveDate >= fromDate && Tra.EffectiveDate <= toDate && Tra.TransactionState != TransactionState.Declined).ToList();
            }
            else
            {
                var stateEnum = (TransactionState)Enum.Parse(typeof(TransactionState), state);
                reportData = new TransactionService().RetrieveTransactionByCycle(null).Where(Tra => Tra.EffectiveDate >= fromDate && Tra.EffectiveDate <= toDate && Tra.TransactionState == stateEnum).ToList();
            }
            return(reportData.GroupBy(Tra => new { Tra.Comment, SenderId = Tra.Sender.EmployeeId, ReceiverId = Tra.Recipient.EmployeeId }).Select(TraGroup =>
                                                                                                                                                  new ReportData
            {
                Sender = TraGroup.First().IsAnonymous ? "Anonymous" : TraGroup.First().Sender.DisplayName,
                Receiver = TraGroup.First().Recipient.DisplayName,
                Comment = TraGroup.First().Comment,
                Count = TraGroup.Count()
            }).ToList());
        }
Пример #2
0
        public ActionResult ReportDataView(ReportViewModel report)
        {
            if (!CurrentUser.IsAdmin)
            {
                throw new Exception("Unauthorized user access");
            }
            List <TransactionModel> reportData = null;

            if (report.State == "All")
            {
                reportData = new TransactionService().RetrieveTransactionByCycle(null).Where(Tra => Tra.EffectiveDate >= report.FromDate && Tra.EffectiveDate <= report.ToDate).ToList();
            }
            else
            {
                var state = (TransactionState)Enum.Parse(typeof(TransactionState), report.State);
                reportData = new TransactionService().RetrieveTransactionByCycle(null).Where(Tra => Tra.EffectiveDate >= report.FromDate && Tra.EffectiveDate <= report.ToDate && Tra.TransactionState == state).ToList();
            }

            //TODO Shouldn't be using ViewBag
            ViewBag.FromDate = report.FromDate;
            ViewBag.ToDate   = report.ToDate;
            ViewBag.State    = report.State;

            if (reportData != null)
            {
                var viewModel = reportData.GroupBy(Tra => new { Tra.Comment, SenderId = Tra.Sender.EmployeeId, ReceiverId = Tra.Recipient.EmployeeId }).Select(TraGroup =>
                                                                                                                                                               new ReportDataViewModel
                {
                    Sender   = TraGroup.First().IsAnonymous ? "Anonymous" : TraGroup.First().Sender.DisplayName,
                    Receiver = TraGroup.First().Recipient.DisplayName,
                    Comment  = TraGroup.First().Comment,
                    Count    = TraGroup.Count()
                });
                return(PartialView("~/Views/Admin/_ReportTable.cshtml", viewModel.ToPagedList(report.Page ?? 1, 20)));
            }
            return(PartialView("~/Views/Admin/_ReportTable.cshtml", null));
        }
Пример #3
0
 public long GetSpentCoinsCountForCurrentCycle()
 {
     return(RetrieveTransactionByStateAndCycle(TransactionState.Delivered, null).OrderByDescending(Tra => Tra.EffectiveDate).GroupBy(Tra => Tra.GritCoin.CoinNumber)
            .Select(TraGroup => TraGroup.First().SpentDate != null).Count(Res => Res == true));
 }