Exemplo n.º 1
0
        /// <summary>
        /// Constructs and AboutItemsViewModel with an item that matches
        /// the given interactionType.
        /// </summary>
        public AboutItemsViewModel GetAboutItemsViewModel(string interactionTypeCode = "")
        {
            var interactionTypes = context.AboutInteractionTypes;

            if (string.IsNullOrWhiteSpace(interactionTypeCode))
            {
                interactionTypeCode = interactionTypes.FirstOrDefault()?.Code;
            }

            var items = context.SampleItems
                        .Where(i => i.Grade != GradeLevels.NA && i.InteractionType != null)
                        .OrderBy(i => (int)i.Grade);

            SampleItem sampleItem = items.FirstOrDefault(item => item.InteractionTypeSubCat == interactionTypeCode)
                                    ?? items.FirstOrDefault(item => interactionTypeCode == item.InteractionType.Code)
                                    ?? items.FirstOrDefault(item => interactionTypeCode.Contains(item.InteractionType.Code));

            string itemURL = GetItemViewerUrlSingleItem(sampleItem);

            AboutThisItemViewModel aboutThisItemViewModel = GetAboutThisItemViewModel(sampleItem);
            AboutItemsViewModel    model = new AboutItemsViewModel(
                interactionTypes: interactionTypes,
                itemUrl: itemURL,
                selectedCode: interactionTypeCode,
                aboutThisItemViewModel: aboutThisItemViewModel);

            return(model);
        }
Exemplo n.º 2
0
 public AboutItemsViewModel(
     ImmutableArray <InteractionType> interactionTypes,
     string itemUrl,
     string selectedCode,
     AboutThisItemViewModel aboutThisItemViewModel)
 {
     InteractionTypes            = interactionTypes;
     ItemUrl                     = itemUrl;
     SelectedInteractionTypeCode = selectedCode ?? interactionTypes.FirstOrDefault()?.Code;
     AboutThisItemViewModel      = aboutThisItemViewModel;
 }