Пример #1
0
        public IViewComponentResult Invoke()
        {
            var contact = contactRepository.GetCompanyContact();
            var model   = ContactViewModel.GetViewModel(contact, countryRepository, localizer);

            return(View("~/Components/ViewComponents/CompanyAddress/Default.cshtml", model));
        }
 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));
 }