Exemplo n.º 1
0
        public async Task <AppointmentServiceObject> CreateAppointmentAsync(AppointmentServiceObject appointmentServiceObject, CancellationToken token)
        {
            var appointmentEntity = _mapper.Map <AppointmentEntity>(appointmentServiceObject);
            var createdEntity     = await _appointmentRepository.CreateAppointmentAsync(appointmentEntity, token);

            return(_mapper.Map <AppointmentServiceObject>(createdEntity));
        }
Exemplo n.º 2
0
        public async Task <AppointmentModel> Handle(UpdateAppointmentCommand request, CancellationToken cancellationToken)
        {
            long insertedId = await _repository.CreateAppointmentAsync(new Appointment()
            {
                DateAt      = request.DateAt,
                Description = request.Description,
                Completed   = false,
                Specialist  = new Specialist()
                {
                    Id = request.SpecialistId
                },
                Patient = new Patient()
                {
                    Id = request.PatientId
                },
                CreatedBy      = "APPLICATION",
                LastModified   = DateTime.UtcNow,
                LastModifiedBy = "APPLICATION"
            });

            var appointment = await _repository.GetAppointmentByIdAsync(insertedId);

            return(new AppointmentModel()
            {
                Id = appointment.Id,
                DateAt = appointment.DateAt,
                Completed = appointment.Completed,
                Specialist = new SpecialistModel()
                {
                    Id = appointment.Specialist.Id,
                    Names = appointment.Specialist.Names,
                    Surnames = appointment.Specialist.Surnames
                },
                Patient = new PatientModel()
                {
                    Id = appointment.Patient.Id,
                    Names = appointment.Patient.Names,
                    Surnames = appointment.Patient.Surnames
                }
            });
        }