Beispiel #1
0
 public static IReadOnlyCollection <DateTime> GetPreviousWeekDates(this IWeekDatesProvider provider, DateTime dateTime)
 {
     return(provider.GetWeekDates
            (
                dateTime,
                days: -7,
                DayOfWeek.Monday
            ));
 }
Beispiel #2
0
 public ScheduleCommand(ILogger <ScheduleCommand> logger, ITelegramBotClient client, IScheduleParser scheduleParser,
                        IChatParametersService chatParametersService, ICallbackQueryListener callbackQueryListener, IWeekDatesProvider weekDatesProvider)
 {
     _logger                = logger;
     _client                = client;
     _scheduleParser        = scheduleParser;
     _chatParametersService = chatParametersService;
     _callbackQueryListener = callbackQueryListener;
     _weekDatesProvider     = weekDatesProvider;
 }
Beispiel #3
0
        public static IReplyMarkup ToWeekDatesKeyboard(this DateTime dateTime, IWeekDatesProvider weekDatesProvider)
        {
            var previousWeekDates = weekDatesProvider.GetPreviousWeekDates(dateTime);

            var previousWeekStartDate = previousWeekDates.First()
                                        .ToShortDateString();

            var previousWeekEndDate = previousWeekDates.Last()
                                      .ToShortDateString();

            var nextWeekDates = weekDatesProvider.GetNextWeekDates(dateTime);

            var nextWeekStartDate = nextWeekDates.First()
                                    .ToShortDateString();

            var nextWeekEndDate = nextWeekDates.Last()
                                  .ToShortDateString();

            return(new InlineKeyboardMarkup
                   (
                       new List <List <InlineKeyboardButton> >()
            {
                new List <InlineKeyboardButton>()
                {
                    InlineKeyboardButton.WithCallbackData
                    (
                        text: $"{previousWeekStartDate} - {previousWeekEndDate}",
                        callbackData: previousWeekStartDate
                    )
                },
                new List <InlineKeyboardButton>()
                {
                    InlineKeyboardButton.WithCallbackData
                    (
                        text: $"Текущая неделя",
                        callbackData: dateTime.ToShortDateString()
                    )
                },
                new List <InlineKeyboardButton>()
                {
                    InlineKeyboardButton.WithCallbackData
                    (
                        text: $"{nextWeekStartDate} - {nextWeekEndDate}",
                        callbackData: nextWeekStartDate
                    )
                }
            }
                   ));
        }