コード例 #1
0
        public IEnumerable <EventModel> Get()
        {
            var settings = new Data.Access.Queries.Settings.Get(_context, new[]
            {
                SettingName.DaysInFutureToDisplay,
                SettingName.IcalUrl,
                SettingName.TimeZoneOffsetFromUtcInHours
            }).ExecuteAndReturnResults();

            var displayDaysIntoFuture        = 30;
            var displayDaysIntoFutureSetting = settings.FirstOrDefault(x => x.Name == SettingName.DaysInFutureToDisplay);

            if (displayDaysIntoFutureSetting != null)
            {
                int.TryParse(displayDaysIntoFutureSetting.Value, out displayDaysIntoFuture);
            }

            var iCalUrl = settings.FirstOrDefault(x => x.Name == SettingName.IcalUrl)?.Value?.ToString() ?? string.Empty;
            var offset  = -6;

            Int32.TryParse(settings.FirstOrDefault(x => x.Name == SettingName.TimeZoneOffsetFromUtcInHours)?.Value?.ToString() ?? (-6).ToString(), out offset);

            var iCalEvents   = new List <EventModel>();
            var systemEvents = new List <EventModel>();

            Parallel.Invoke(
                () => systemEvents = GetSystemEvents(displayDaysIntoFuture),
                () => iCalEvents   = GetICalEvents(iCalUrl, displayDaysIntoFuture, offset)
                );

            return(iCalEvents.Union(systemEvents).OrderBy(x => x.Begins));
        }
コード例 #2
0
        public IAddress Map(string address)
        {
            var      apiKey   = new Data.Access.Queries.Settings.Get(_context, new[] { SettingName.GoogleMapsDeveloperApiKey }).ExecuteAndReturnResults().FirstOrDefault()?.Value;
            IAddress _address = new GoogleMap(apiKey).GetAddress(address);

            return(_address);
        }