Example #1
0
        public async Task Create(Model.Timeslot slot)
        {
            slot.ValidateDates();
            slot.RemoveSeconds();
            var slotList = slot.DetermineSingleOrCollectionTimeslots();

            slotList = await TryAddToTeacher(slotList);

            foreach (var s in slotList)
            {
                await timeslotCommand.Create(s);
            }
        }
Example #2
0
        public async Task TryBookTimeslot(Model.Timeslot timeslot, Model.Booking booking)
        {
            if (timeslot.StartDateTime < DateTime.Now)
            {
                throw new Exception("Cannot book old date");
            }
            var studentId = await state.GetPersonIdAsync();

            booking.StudentId = studentId;
            var student = await studentQuery.GetStudentWithFutureBookings(studentId);

            student.AddBooking(booking);
            await bookingCommand.Create(booking);

            var slot = await timeslotQuery.GetSingle(timeslot.Id);

            slot.BookingId = booking.Id;
            slot.Booking   = booking;
            await timeslotCommand.UpdateWithConcurrencyCheck(slot);
        }