コード例 #1
0
        public IActionResult GetUserAgendas()
        {
            var model = agendaService.GetAllOpen()
                        .Select(o => mapper.Map <AgendaVM>(o))
                        .OrderBy(o => o.Title)
                        .ToList();

            return(PartialView("_Agendas", model));
        }
コード例 #2
0
        public IActionResult GetAgendas()
        {
            var model = new List <DashboardAgendaVM>();

            var agendas = agendaService.GetAllOpen();

            foreach (var agenda in agendas)
            {
                var agendaVM = new DashboardAgendaVM
                {
                    Id                  = agenda.Id,
                    Title               = agenda.Title,
                    CreatedAt           = agenda.CreatedAt,
                    Deadline            = agenda.Deadline,
                    CompletedItemsCount = agenda.Items.Where(o => o.Completed == true).Count(),
                    TotalItemsCount     = agenda.Items.Count(),
                    Categories          = new List <DashboardCategoryVM>()
                };
                var categories = agenda.Items.GroupBy(o => o.Category);
                foreach (var category in categories)
                {
                    var categoryVM = new DashboardCategoryVM
                    {
                        Title = category.FirstOrDefault().Category,
                        Items = category.Select(o => new DashboardItemVM
                        {
                            Id          = o.Id,
                            Description = o.Description,
                            Completed   = o.Completed
                        })
                                .ToList()
                    };
                    agendaVM.Categories.Add(categoryVM);
                }
                model.Add(agendaVM);
            }

            return(PartialView("_Agendas", model));
        }