Exemple #1
0
        public async Task StartBreak(WorkDay workDay)
        {
            if (workDay == null)
            {
                throw new ArgumentNullException();
            }

            if (workDay.IsInBreak())
            {
                throw new AlreadyInBreakException();
            }

            var newBreak = new Break()
            {
                Start = DateTimeOffset.Now
            };

            newBreak.WorkDayId = workDay.Id;

            await _databaseConnection.InsertAsync(newBreak);

            workDay.Breaks.Add(newBreak);

            //newBreak.WorkDay = workDay;
            await _databaseConnection.UpdateWithChildrenAsync(workDay);

            FireDayUpdatedEvent(workDay);
        }
Exemple #2
0
        public async Task EndBreak(WorkDay workDay)
        {
            if (workDay == null)
            {
                throw new ArgumentNullException();
            }

            if (!workDay.IsInBreak())
            {
                throw new NotInBreakException();
            }

            workDay.LastBreak.End = DateTimeOffset.Now;

            await _databaseConnection.UpdateWithChildrenAsync(workDay.LastBreak);

            FireDayUpdatedEvent(workDay);
        }