Esempio n. 1
0
        public Task <int> Handle(RequestBooking request, CancellationToken cancellationToken)
        {
            var booking = new Booking(
                request.PatientRequest.DateFrom,
                request.PatientRequest.DateTo);

            booking.AssignPatient(request.PatientRequest.PatientId);

            request.SurgeonRequests.ForEach(sr =>
            {
                var surgeon = booking.AssignSurgeon(sr.SurgeonId);
                sr.AssistantIds?.ForEach(a => booking.AssignSurgeonAssistant(surgeon, a));
                sr.ProcedureIds.ForEach(p => booking.AssignSurgeonProcedure(surgeon, p));
            });

            booking.Request();

            _bookingRepository.Add(booking);

            _bookingRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);

            return(Task.FromResult(0));
        }