Exemplo n.º 1
0
        public static VacationInfoRequest TryParse(BotRequest botRequest)
        {
            Match match = RegexQuestion.Match(botRequest.Text);

            if (match.Success)
            {
                var user = match.Groups[1].Value;
                if (user.StartsWith("<@"))
                {
                    return(new VacationInfoRequest()
                    {
                        SlackId = match.Groups[1].Value
                    });
                }
                else
                {
                    return(new VacationInfoRequest()
                    {
                        FullName = match.Groups[1].Value
                    });
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public static SetVacationRequest TryParse(BotRequest botRequest)
        {
            Match match = RegexQuestion.Match(botRequest.Text);

            if (match.Success)
            {
                DateTime fromDate;
                var      fromIsValid = DateTime.TryParseExact(
                    match.Groups[1].Value,
                    "dd.MM.yyyy",
                    CultureInfo.InvariantCulture, DateTimeStyles.None, out fromDate);
                DateTime toDate;
                var      toIsValid = DateTime.TryParseExact(
                    match.Groups[2].Value,
                    "dd.MM.yyyy",
                    CultureInfo.InvariantCulture, DateTimeStyles.None, out toDate);
                if (fromIsValid && toIsValid)
                {
                    return(new SetVacationRequest()
                    {
                        From = fromDate, To = toDate
                    });
                }
            }

            return(null);
        }