Ejemplo n.º 1
0
        public ActionResult Index(RenderModel model, GetEventsConfiguration configuration)
        {
            // TODO: These two methods might be worth moving into MVC attributes
            OverridePaging(configuration);
            ValidateLocationSelection(configuration);

            // TODO: A lot of this code could be refactored out into a service
            var selectedLocationNode = configuration.LocationId.HasValue
                                ? _umbracoWrapper.TypedContent(configuration.LocationId.Value)
                                : model.Content;
            var viewModel = _modelConverter.ToModel <FeedViewModel>(selectedLocationNode);

            viewModel.Countries = Countries(model.Content, configuration);

            if (!configuration.CountryId.HasValue)
            {
                configuration.CountryId = viewModel.Countries.First().Id;
            }

            viewModel.Cities = SubLocations(configuration.CountryId, configuration.CityId);
            viewModel.Venues = SubLocations(configuration.CityId, configuration.VenueId);
            viewModel.Events = _eventSearchService.GetVenueEvents(configuration).ToModel <EventViewModel>();

            return(View("~/Views/Feed.cshtml", viewModel));
        }
Ejemplo n.º 2
0
        private VenueViewModel ToVenueViewModel(IEnumerable <IPublishedContent> events)
        {
            var venue = _modelConverter.ToModel <VenueViewModel>(events.First().Parent);

            venue.Events = _modelConverter.ToModel <EventViewModel>(events);
            return(venue);
        }
Ejemplo n.º 3
0
 public long CreateItem(long ownerId, Item item)
 {
     Maple2.Sql.Model.Item model = itemConverter.ToModel(item);
     model.OwnerId = ownerId;
     context.Item.Add(model);
     context.SaveChanges();
     return(model.Id);
 }
Ejemplo n.º 4
0
        public SubNavigationModel <T> GetSubNavigation(string url)
        {
            var content = _umbracoWrapper.TypedContent(url.TrimEnd('/'));

            if (content == null)
            {
                return(null);
            }

            var model          = new SubNavigationModel <T>();
            var topLevelParent = _umbracoWrapper.AncestorOrSelf(content, 2);

            model.SectionParent      = _modelConverter.ToModel <UmbracoNavigationElement>(topLevelParent);
            model.NavigationElements = GetNavigationElements(topLevelParent);
            return(model);
        }
Ejemplo n.º 5
0
        private NavigationNode NavigationNode(IPublishedContent content)
        {
            var node = _modelConverter.ToModel <NavigationNode>(content);

            node.Active   = Context.Content.Url == node.Url;
            node.Children = content.Children.Select(NavigationNode);
            return(node);
        }
Ejemplo n.º 6
0
 public override object ProcessValue()
 {
     return(_umbracoWrapper.AncestorOrSelf(Context.Content, 1)
            .Children.First(x => x.DocumentTypeAlias.Equals("locations"))
            .Children()
            .Where(x => x.Children.Any())
            .Select(x => _modelConverter.ToModel <LocationOption>(x))
            .ToList());
 }
Ejemplo n.º 7
0
        private IEnumerable <IContentSearchResult> AsContentSearchResults(IEnumerable <IPublishedContent> results)
        {
            foreach (var content in results)
            {
                switch (content.DocumentTypeAlias)
                {
                case "event":
                    yield return(_modelConverter.ToModel <EventContentSearchResult>(content));

                    break;

                case "venue":
                    yield return(_modelConverter.ToModel <VenueContentSearchResult>(content));

                    break;
                }
            }
        }
Ejemplo n.º 8
0
 public override object ProcessValue()
 {
     return(_umbracoWrapper.AncestorOrSelf(Context.Content, 1)
            .Children.First(x => x.DocumentTypeAlias.Equals("locations"))
            .Descendants()
            .Where(x => x.DocumentTypeAlias == "venue")
            .SelectMany(x => x.Children)
            .Select(x => _modelConverter.ToModel <EventViewModel>(x))
            .ToList());
 }
        public Maple2.Sql.Model.BlackMarketListing ToModel(BlackMarketListing value,
                                                           Maple2.Sql.Model.BlackMarketListing listing)
        {
            if (value == null)
            {
                return(null);
            }

            listing ??= new Maple2.Sql.Model.BlackMarketListing();
            listing.Id          = value.Id;
            listing.AccountId   = value.AccountId;
            listing.CharacterId = value.CharacterId;
            listing.ExpiryTime  = value.ExpiryTime.FromEpochSeconds();
            listing.Price       = value.Price;
            listing.Item        = itemConverter.ToModel(value.Item, listing.Item);

            return(listing);
        }
        public override object ProcessValue()
        {
            if (string.IsNullOrEmpty(Value?.ToString()))
            {
                return(null);
            }

            var gridContentModel = JsonConvert.DeserializeObject <GridContentModel>(Value.ToString());

            foreach (var control in (from section in gridContentModel.Sections from row in section.Rows from area in row.Areas from control in area.Controls select control).Where(control => control.Value != null))
            {
                switch (control.Editor.Alias)
                {
                case GridEditorAliases.Embed:
                case GridEditorAliases.Quote:
                    control.QuoteOrEmbed = control.Value.ToString();
                    break;

                case GridEditorAliases.Media:
                    var gridContentMediaValue = JsonConvert.DeserializeObject <GridContentMediaValue>(control.Value.ToString());
                    var mediaImage            = _modelConverter.ToModel <GridContentMediaValue>(_mediaService.Media(gridContentMediaValue.Id));
                    mediaImage.Caption = gridContentMediaValue.Caption;
                    control.MediaImage = mediaImage;
                    break;

                case GridEditorAliases.Rte:
                    control.Html = new MvcHtmlString(TemplateUtilities.ParseInternalLinks(control.Value.ToString()));
                    break;

                case GridEditorAliases.Headline:
                    control.Text = control.Value.ToString();
                    break;

                default:
                    throw new ArgumentException("unknown grid editor aliases", control.Editor.Alias);
                }
            }

            return(gridContentModel);
        }
        public T GetUmbracoContentModel <T>(IPublishedContent currentPage) where T : class
        {
            var model = _modelConverter.ToModel <T>(currentPage);

            return(model);
        }
Ejemplo n.º 12
0
 private async Task Store(List <RecordProcessingResult> buffer)
 {
     var models = buffer.Where(pr => pr.Success).Select(pr => _converter.ToModel(pr.Record));
     await _db.BulkUpsert(models).ConfigureAwait(false);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// converts the passed umbraco content into a site media image
 /// </summary>
 private static MediaImageModel ConvertImage(IModelConverter modelConverter, Type type, IPublishedContent image)
 {
     return((MediaImageModel)modelConverter.ToModel(type, image));
 }