コード例 #1
0
        public IViewComponentResult Invoke()
        {
            var contact = contactRepository.GetCompanyContact();
            var model   = ContactViewModel.GetViewModel(contact, countryRepository, localizer);

            return(View("~/Components/ViewComponents/CompanyAddress/Default.cshtml", model));
        }
コード例 #2
0
 public static CafeViewModel GetViewModel(Cafe cafe, ICountryRepository countryRepository, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(new CafeViewModel
     {
         PhotoPath = cafe.Fields.Photo == null ? null : attachmentUrlRetriever.Retrieve(cafe.Fields.Photo).RelativePath,
         Note = cafe.Fields.AdditionalNotes,
         Contact = ContactViewModel.GetViewModel(cafe, countryRepository)
     });
 }
コード例 #3
0
        private Dictionary <string, List <ContactViewModel> > GetPartnerCafesModel(IEnumerable <Cafe> cafes)
        {
            var cityCafes = new Dictionary <string, List <ContactViewModel> >();

            // Group partner cafes by their location
            foreach (var cafe in cafes)
            {
                var city    = cafe.City.ToLowerInvariant();
                var contact = ContactViewModel.GetViewModel(cafe, countryRepository, localizer);

                if (cityCafes.ContainsKey(city))
                {
                    cityCafes[city].Add(contact);
                }
                else
                {
                    cityCafes.Add(city, new List <ContactViewModel> {
                        contact
                    });
                }
            }

            return(cityCafes);
        }
コード例 #4
0
 private List <ContactViewModel> GetCompanyCafesModel(IEnumerable <Cafe> cafes)
 {
     return(cafes.Select(cafe => ContactViewModel.GetViewModel(cafe, countryRepository, localizer)).ToList());
 }
コード例 #5
0
 private ContactViewModel GetCompanyContactModel()
 {
     return(ContactViewModel.GetViewModel(contactRepository.GetCompanyContact(), countryRepository, localizer));
 }