예제 #1
0
        private Airing MapAiring(AiringLong airingView)
        {
            var airingStart = GetEarliestStartDate(airingView);
            var airingEnd   = GetLatestEndDate(airingView);
            var linearStart = GetLinearDateTime(airingView);

            var airingData = new Airing
            {
                AiringId           = airingView.AssetId,
                Name               = airingView.Name,
                Type               = airingView.Type,
                AiringTitles       = MapTitleIds(airingView),
                AiringDestinations = MapDestinations(airingView),
                Brand              = airingView.Network,
                StartDateTime      = airingStart,
                EndDateTime        = airingEnd,
                LinearDateTime     = linearStart,
                ESTStartDateTime   = airingStart.HasValue ? (DateTime?)ConvertToEst(airingStart.Value) : null,
                ESTEndDateTime     = airingEnd.HasValue ? (DateTime?)ConvertToEst(airingEnd.Value) : null,
                ESTLinearDateTime  = linearStart.HasValue ? (DateTime?)ConvertToEst(linearStart.Value) : null,
                BCStartDateTime    = airingStart.HasValue ? (DateTime?)ConvertToBc(ConvertToEst(airingStart.Value)) : null,
                BCEndDateTime      = airingEnd.HasValue ? (DateTime?)ConvertToBc(ConvertToEst(airingEnd.Value)) : null,
                BCLinearDateTime   = linearStart.HasValue ? (DateTime?)ConvertToBc(ConvertToEst(linearStart.Value)) : null,
                UpdatedDateTime    = DateTime.UtcNow
            };

            return(airingData);
        }
예제 #2
0
 private ICollection <AiringTitle> MapTitleIds(AiringLong airing)
 {
     return(airing.Title.TitleIds.Where(t => t.Authority.Equals("Turner")).Select(titleId => new AiringTitle
     {
         AiringId = airing.AssetId,
         TitleId = int.Parse(titleId.Value)
     }).ToList());
 }
예제 #3
0
        private DateTime?GetLatestEndDate(AiringLong airingView)
        {
            var flight = airingView.Flights.OrderByDescending(f => f.End).FirstOrDefault();

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

            return(flight.End);
        }
예제 #4
0
        private DateTime?GetEarliestStartDate(AiringLong airingView)
        {
            var flight = airingView.Flights.OrderBy(f => f.Start).FirstOrDefault();

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

            return(flight.Start);
        }
예제 #5
0
        private ICollection <AiringDestination> MapDestinations(AiringLong airing)
        {
            var destinations = new List <AiringDestination>();

            foreach (var flight in airing.Flights)
            {
                foreach (var destination in flight.Destinations)
                {
                    var existingDestination = destinations.FirstOrDefault(d => d.Destination == destination.Name);

                    if (existingDestination != null)
                    {
                        existingDestination.DestinationFlights.Add(new DestinationFlight
                        {
                            Destination = destination.Name,
                            StartDate   = flight.Start,
                            EndDate     = flight.End
                        });
                    }
                    else
                    {
                        destinations.Add(new AiringDestination
                        {
                            AiringId           = airing.AssetId,
                            Destination        = destination.Name,
                            DestinationFlights = new Collection <DestinationFlight> {
                                new DestinationFlight
                                {
                                    Destination = destination.Name,
                                    StartDate   = flight.Start,
                                    EndDate     = flight.End
                                }
                            }
                        });
                    }
                }
            }

            return(destinations);
        }
예제 #6
0
 private DateTime?GetLinearDateTime(AiringLong airingView)
 {
     return((airingView.Airings.Any() && airingView.Airings.First().Linked) ? airingView.Airings.First().Date : null);
 }