// GET: App/Colleague/Details/5
        public async Task <IActionResult> Details(int?id, string FromDate = "", string ToDate = "")
        {
            if (id == null)
            {
                ViewBag.err = new NotFoundException();
                return(View("Error"));
            }

            Colleague colleague;

            try
            {
                colleague = await colleagues.GetByIdAsync(id.Value);
            }
            catch (Exception ex)
            {
                ViewBag.err = ex;
                return(View("Error"));
            }

            List <DateTime> months    = this.GetFirstOfAllSolarMonth();
            string          ChartData = "[";

            for (int i = 0; i < months.Count - 1; i++)
            {
                double sum          = 0;
                var    transactions = colleagues.GetFromToTransactionByColleagueIdAsync(id.Value, months[i], months[i + 1]);
                sum = transactions
                      .Select(x =>
                              (x.MyTransaction?.Amount ?? 0) + (x.MyReceipt?.Amount ?? 0))
                      .Sum();

                ChartData += sum.ToString();
                ChartData += ", ";
            }
            ChartData         = ChartData.Substring(0, ChartData.Length - 1) + "]";
            ViewBag.ChartData = ChartData;

            ViewBag.FromDate = FromDate;
            ViewBag.ToDate   = ToDate;
            return(View(colleague));
        }
Ejemplo n.º 2
0
        // GET: App/SponsorTransaction/Create
        public async Task <IActionResult> CreateAsync(int?id, string RedirectTo)
        {
            if (id == null)
            {
                return(View());
            }

            Colleague c;

            try
            {
                c = await colleages.GetByIdAsync(id.Value);
            }
            catch (Exception ex)
            {
                ViewBag.err = ex;
                return(View("Error"));
            }

            ViewBag.ColleagueID   = id.Value;
            ViewBag.RedirectTo    = RedirectTo;
            ViewData["SponsorID"] = new SelectList(c.Sponsors, "SponsorID", "Name");
            return(View());
        }