Exemplo n.º 1
0
        public override Result <string> Execute(Match regexMatch)
        {
            Result <string> SaveStash(Status status)
            {
                return(repository.SaveStash(TimeSpan.Zero)
                       .Bind(_ => todaysSheet.ExecuteWithHeader()));
            }

            return(repository.GetStatus().Bind(SaveStash));
        }
Exemplo n.º 2
0
        public override Result <string> Execute(Match regexMatch)
        {
            DateTime today   = DateTime.Today;
            int      hour    = int.Parse(regexMatch.Groups["hour"].Value);
            int      minute  = int.Parse(regexMatch.Groups["minute"].Value);
            DateTime newTime = new DateTime(today.Year, today.Month, today.Day, hour, minute, 0);

            return(repository.GetStatus()
                   .Bind(s => repository.SaveTodaySheet(s.Day.FixStartTime(newTime)))
                   .Bind(_ => todaysSheet.ExecuteWithHeader()));
        }
Exemplo n.º 3
0
        public override Result <string> Execute(Match regexMatch)
        {
            Result <object> flushToPause(Status status)
            {
                return(repository.SaveTodaySheet(status.Day.AddToPause(status.UnregisteredTime)));
            }

            return(repository.GetStatus()
                   .Bind(s => flushToPause(s))
                   .Bind(_ => repository.SaveStash(TimeSpan.Zero))
                   .Bind(_ => todaysSheet.ExecuteWithHeader()));
        }
Exemplo n.º 4
0
        public override Result <string> Execute(Match regexMatch)
        {
            Result <object> addToPause(Day sheet, TimeSpan p)
            {
                return(repository.SaveTodaySheet(sheet.AddToPause(p)));
            }

            TimeSpan absPause = TimeSpan.FromMinutes(int.Parse(regexMatch.Groups["minutes"].Value));
            TimeSpan pause    = regexMatch.Groups["minus"].Success ? absPause.Negate() : absPause;

            return(repository.GetStatus()
                   .Bind(s => addToPause(s.Day, pause))
                   .Bind(_ => todaysSheet.ExecuteWithHeader()));
        }