Ejemplo n.º 1
0
        public ActionResult List(OrganizationFilterViewModel filterViewModel)
        {
            InitOrganizationFilterViewModel(ref filterViewModel, true);
            var filter = Mapper.Map <OrganizationFilter>(filterViewModel);
            OrganizationItems          list      = _organizationRepository.GetOrganizationItems(UserContext.User.Id, UserContext.User.OrganizationId, filter);
            OrganizationItemsViewModel viewModel = Mapper.Map <OrganizationItemsViewModel>(list);

            viewModel.Filter = filterViewModel;
            InitListViewModel(viewModel, list);

            return(View(Mvc.View.Organization.List, viewModel));
        }
Ejemplo n.º 2
0
 private void InitListViewModel(OrganizationItemsViewModel viewModel, OrganizationItems list)
 {
     foreach (var item in viewModel.Items)
     {
         InitBaseItemViewModel(item);
         item.Heads = list
                      .Members
                      .Where(om => om.OrganizationId == item.Id && om.MemberTypeId == Dom.MemberType.Head)
                      .ToDictionary(t => t.MemberId, t => Format.FormattedInitials(t.LastName, t.FirstName, t.MiddleName));
         item.Judges = list
                       .Members
                       .Where(om => om.OrganizationId == item.Id && (om.MemberTypeId == Dom.MemberType.MainJudge || om.MemberTypeId == Dom.MemberType.Judge))
                       .Select(m => new
         {
             Key   = m.MemberId,
             Value = Format.FormattedInitials(m.LastName, m.FirstName, m.MiddleName)
         })
                       .Distinct()
                       .ToDictionary(t => t.Key, t => t.Value);
     }
 }