Esempio n. 1
0
 public static ScheduledStreamEditModel ToEditViewModel(this ScheduledStream src)
 {
     return(new ScheduledStreamEditModel
     {
         Id = src.Id,
         DayOfWeek = src.DayOfWeek,
         LocalStartTime = TimePattern.Format(src.LocalStartTime),
         LocalEndTime = TimePattern.Format(src.LocalEndTime)
     });
 }
Esempio n. 2
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                return(_pattern.Format((LocalTime)value));
            }
            if (destinationType == typeof(DateTime))
            {
                return(DateTime.MinValue.AddTicks(((LocalTime)value).TickOfDay));
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
        public async Task <IActionResult> Get([FromServices] BackOfficeContext context)
        {
            var entries = new List <ChangeFeedEntry>();
            await context
            .RoadNetworkChanges
            .OrderByDescending(_ => _.Id)
            .ForEachAsync(change =>
            {
                var when      = InstantPattern.ExtendedIso.Parse(change.When).GetValueOrThrow();
                var localWhen = when.InZone(_localTimeZone).LocalDateTime;
                var item      = new ChangeFeedEntry
                {
                    Id        = change.Id,
                    Title     = change.Title,
                    Type      = change.Type,
                    Day       = localWhen.Day.ToString("00"),
                    Month     = _localMonthPattern.Format(localWhen.Date),
                    TimeOfDay = _localTimeOfDayPattern.Format(localWhen.TimeOfDay)
                };
                switch (change.Type)
                {
                case nameof(BeganRoadNetworkImport):
                    item.Content = null;
                    break;

                case nameof(CompletedRoadNetworkImport):
                    item.Content = null;
                    break;

                case nameof(RoadNetworkChangesArchiveUploaded):
                    item.Content = JsonConvert.DeserializeObject(change.Content,
                                                                 typeof(RoadNetworkChangesArchiveUploadedEntry));
                    break;

                case nameof(RoadNetworkChangesArchiveAccepted):
                    item.Content = JsonConvert.DeserializeObject(change.Content,
                                                                 typeof(RoadNetworkChangesArchiveAcceptedEntry));
                    break;

                case nameof(RoadNetworkChangesArchiveRejected):
                    item.Content = JsonConvert.DeserializeObject(change.Content,
                                                                 typeof(RoadNetworkChangesArchiveRejectedEntry));
                    break;

                case nameof(RoadNetworkChangesBasedOnArchiveAccepted):
                    item.Content = JsonConvert.DeserializeObject(change.Content,
                                                                 typeof(RoadNetworkChangesBasedOnArchiveAcceptedEntry));
                    break;

                case nameof(RoadNetworkChangesBasedOnArchiveRejected):
                    item.Content = JsonConvert.DeserializeObject(change.Content,
                                                                 typeof(RoadNetworkChangesBasedOnArchiveRejectedEntry));
                    break;
                }

                entries.Add(item);
            }, HttpContext.RequestAborted);

            return(new JsonResult(new ChangeFeedResponse
            {
                Entries = entries.ToArray()
            })
            {
                StatusCode = StatusCodes.Status200OK
            });
        }
 public override string ToString(object val)
 {
     return(_timePattern.Format((LocalTime)val));
 }
Esempio n. 5
0
 public void IsoPatternToSecond_Format() =>
 IsoPatternToSecond.Format(SampleLocalTimeToSecond);