public async Task<int> AddAsync(ClinicAppointment appointment)
        {
            // these properties are updated for demo porpouse.
            if (appointment.RoomNumber == 0)
                appointment.RoomNumber = Randomize.Next(3, 15);

            if (string.IsNullOrEmpty(appointment.Description))
                appointment.Description = "Follow up in order to determine the effectiveness of treatment received";

            _context.ClinicAppointments.Add(appointment);
            await _context.SaveChangesAsync();
            return appointment.AppointmentId;
        }
 ClinicAppointment Build(ClinicAppointment appointment)
 {
     return new ClinicAppointment()
     {
         AppointmentId = appointment.AppointmentId,
         DateTime = appointment.DateTime,
         IsUrgent = appointment.IsUrgent,
         Speciality = appointment.Speciality,
         DoctorId = appointment.DoctorId,
         RoomNumber = appointment.RoomNumber,
         Description = appointment.Description,
         PatientId = appointment.PatientId,
         TenantId = appointment.TenantId,
         Doctor = new Doctor()
         {
             Name = appointment.Doctor.Name,
             Picture = appointment.Doctor.Picture,
             Speciality = appointment.Doctor.Speciality
         },
         Patient = appointment.Patient == null ? null : new Patient()
         {
             PatientId = appointment.Patient.PatientId,
             DateOfBirth = appointment.Patient.DateOfBirth,
             Gender = appointment.Patient.Gender, 
             Name = appointment.Patient.Name,
             ClinicId = appointment.Patient.ClinicId,
             Picture = appointment.Patient.Picture,
             Age = appointment.Patient.Age,
             Email = appointment.Patient.Email,
             Phone = appointment.Patient.Phone,
             BloodType = appointment.Patient.BloodType,
             Weight = appointment.Patient.Weight,
             Height = appointment.Patient.Height
         }
     };
 }
        static void CreateClinicAppointments(MyHealthContext context, int tenantId)
        {
            var appointments = new List<ClinicAppointment>();
            var patients = context.Patients.Select(p => p.PatientId).ToList();
            var doctors = context.Doctors.ToList();

            foreach (int patientId in patients)
            {
                for (int i = 1; i <= AppointmentMonths; i++)
                {
                    var doctor = doctors[Randomize.Next(0, doctors.Count - 1)];
                    var appointment = new ClinicAppointment
                    {
                        PatientId = patientId,
                        DoctorId = doctor.DoctorId,
                        DateTime = GetAppointmentDate(i),
                        Speciality = doctor.Speciality,
                        RoomNumber = Randomize.Next(3, 15),
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        TenantId = tenantId,
                        IsUrgent = true
                    };
                    appointments.Add(appointment);

                    doctor = doctors[Randomize.Next(0, doctors.Count - 1)];
                    appointment = new ClinicAppointment
                    {
                        PatientId = patientId,
                        DoctorId = doctor.DoctorId,
                        DateTime = GetAppointmentDate(i),
                        Speciality = doctor.Speciality,
                        RoomNumber = Randomize.Next(3, 15),
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        TenantId = tenantId,
                        IsUrgent = false
                    };
                    appointments.Add(appointment);

                    doctor = doctors[Randomize.Next(0, doctors.Count - 1)];
                    appointment = new ClinicAppointment
                    {
                        PatientId = patientId,
                        DoctorId = doctor.DoctorId,
                        DateTime = GetAppointmentDate(i),
                        Speciality = doctor.Speciality,
                        RoomNumber = Randomize.Next(3, 15),
                        Description = "Evaluate the diagnosis received",
                        TenantId = tenantId,
                        IsUrgent = true
                    };
                    appointments.Add(appointment);

                    doctor = doctors[Randomize.Next(0, doctors.Count - 1)];
                    appointment = new ClinicAppointment
                    {
                        PatientId = patientId,
                        DoctorId = doctor.DoctorId,
                        DateTime = GetAppointmentDate(i),
                        Speciality = doctor.Speciality,
                        RoomNumber = Randomize.Next(3, 15),
                        Description = "Evaluate the effectiveness of treatment received",
                        TenantId = tenantId,
                        IsUrgent = false
                    };
                    appointments.Add(appointment);
                }
            }

            context.ClinicAppointments.AddRange(appointments);
            context.SaveChanges();
        }