Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Brian McNally 13 posts 91 karma points
    Jun 10, 2014 @ 23:03
    Brian McNally
    0

    MVC Partial View - trouble filtering out expired events

    I have a view pulling in a list of events that have been specified (through the MNTP) to be on that page.

    I'd like to not pull in events that have expired...I'm sure it's a syntax issue but I can't figure out the best way to do this. I have it done on another view but it doesn't seem to work the same way. Any ideas?

    Thanks

    ----------------------------------


    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        string monthYear = String.Empty;
        DateTime today = DateTime.Now;
        var eventContainerId = 1192;
        var categoryId = Model.Content.Id.ToString();
        var events = Umbraco.TypedContent(eventContainerId).Children.Where(x => x.GetPropertyValue<string>("addtopages").Split(',').Contains(categoryId) );
       
    }
    <div class="item w3">
        <div class="panel panel-default">
            <div class="panel-heading"><h3 class="panel-title">Upcoming Education Events</h3></div>
            <div class="panel-body">
                <ul class="listicon">
                    @foreach (var child in events.OrderBy("startdate"))
                    {
                      
                        
                        var fullEventDate =child.GetPropertyValue("startdate");
                        fullEventDate = string.Format("{0:dddd, MMMM d, yyyy}", @fullEventDate);
                        var eventStart = child.GetPropertyValue("startdate");
                        eventStart = string.Format("{0:t}", @eventStart);
                        var eventEnd = child.GetPropertyValue("enddate");
                        eventEnd = string.Format("{0:t}", @eventEnd);
                        
                 
                            
                        <li class="daticon"><a href="@child.Url">@child.Name</a><br/>@fullEventDate<br/>@eventStart -@eventEnd </li>

                    }
                </ul>
            </div>




        </div>
    </div>
  • Brian McNally 13 posts 91 karma points
    Jun 10, 2014 @ 23:29
    Brian McNally
    100

    Please disregard I've tried to delete this topic but that doesn't seem t work. I found a solution probably not the cleanest but the syntax works

     

    DateTime today = DateTime.Now;
    var date2 = child.GetPropertyValue<DateTime>("startdate");

      if (date2 >= today)

                        { 

                        <li class="daticon"><a href="@child.Url">@child.Name</a><br/>@fullEventDate<br/>@eventStart -@eventEnd </li>

                    }

     

Please Sign in or register to post replies

Write your reply to:

Draft