Beispiel #1
0
        public static List <EventConferenceRoomRecord> UpdateEventConferenceRooms(
            IList <string> importConferenceRooms,
            IEventConferenceRoomService service
            )
        {
            var eventConferenceRoomRecords = service.FindAllAsync().Result;

            var patch = new PatchDefinition <string, EventConferenceRoomRecord>(
                (source, list) => list.SingleOrDefault(a => a.Name == source)
                );

            patch.Map(s => s, t => t.Name);
            var diff = patch.Patch(importConferenceRooms, eventConferenceRoomRecords);

            service.ApplyPatchOperationAsync(diff).Wait();

            return(diff.Where(a => a.Entity.IsDeleted == 0).Select(a => a.Entity).ToList());
        }
        private List <EventConferenceRoomRecord> UpdateEventConferenceRooms(
            IList <string> importConferenceRooms,
            ref int modifiedRecords
            )
        {
            var eventConferenceRoomRecords = _eventConferenceRoomService.FindAllAsync().Result;

            var patch = new PatchDefinition <string, EventConferenceRoomRecord>(
                (source, list) => list.SingleOrDefault(a => a.Name == source)
                );

            patch.Map(s => s, t => t.Name);
            var diff = patch.Patch(importConferenceRooms, eventConferenceRoomRecords);

            _eventConferenceRoomService.ApplyPatchOperationAsync(diff).Wait();

            modifiedRecords += diff.Count(a => a.Action != ActionEnum.NotModified);
            return(diff.Where(a => a.Entity.IsDeleted == 0).Select(a => a.Entity).ToList());
        }
 public Task <IEnumerable <EventConferenceRoomRecord> > GetEventsAsync()
 {
     return(_eventConferenceRoomService.FindAllAsync());
 }
Beispiel #4
0
        private async Task <InlineQueryResult[]> QueryEvents(string query)
        {
            if (query.Length < 3)
            {
                return(new InlineQueryResult[0]);
            }

            var events =
                (await _eventService.FindAllAsync(a => a.IsDeleted == 0 && a.Title.ToLower().Contains(query.ToLower())))
                .OrderBy(a => a.StartDateTimeUtc)
                .Take(10)
                .ToList();

            if (events.Count == 0)
            {
                return(new InlineQueryResult[0]);
            }

            var eventConferenceRooms = await _eventConferenceRoomService.FindAllAsync();

            return(events.Select(e =>
            {
                e.ConferenceRoom = eventConferenceRooms.Single(r => r.Id == e.ConferenceRoomId);

                var messageBuilder = new StringBuilder();
                messageBuilder.Append($"*{e.Title}*");

                if (!string.IsNullOrEmpty(e.SubTitle))
                {
                    messageBuilder.Append($" - ({e.SubTitle})");
                }

                messageBuilder.Append(
                    $"\n{e.StartDateTimeUtc.DayOfWeek}, {e.StartTime} to {e.EndTime} in {e.ConferenceRoom.Name}");

                if (!string.IsNullOrEmpty(e.Description))
                {
                    var desc = e.Description;
                    if (desc.Length > 500)
                    {
                        desc = desc.Substring(0, 500) + "...";
                    }
                    messageBuilder.Append($"\n\n_{desc}_");
                }

                messageBuilder.Append($"\n\n[Read more...](https://www.eurofurence.org/EF{_conventionSettings.ConventionNumber}/schedule/events/{e.SourceEventId}.en.html)");

                return new InlineQueryResultArticle()
                {
                    Id = e.Id.ToString(),
                    InputMessageContent = new InputTextMessageContent()
                    {
                        MessageText = messageBuilder.ToString(),
                        ParseMode = ParseMode.Markdown
                    },
                    Title = e.Title + (string.IsNullOrEmpty(e.SubTitle) ? "" : $" ({e.SubTitle})"),
                    Description =
                        $"{e.StartDateTimeUtc.DayOfWeek}, {e.StartDateTimeUtc.Day}.{e.StartDateTimeUtc.Month} - {e.StartTime} until {e.EndTime}"
                };
            })
                   .ToArray());
        }