HomeAppointment Build(HomeAppointment appointment)
 {
     return new HomeAppointment()
     {
         AppointmentId = appointment.AppointmentId,
         Address = appointment.Address,
         Latitude = appointment.Latitude,
         Longitude = appointment.Longitude,
         PatientId = appointment.PatientId,
         DoctorId = appointment.DoctorId,
         TenantId = appointment.TenantId,
         Visited = appointment.Visited,
         Patient = new Patient()
         {
             Name = appointment.Patient.Name,
             Picture = appointment.Patient.Picture,
             ClinicId = appointment.Patient.ClinicId,
         }
     };
 }
        static void CreateHomeAppointments(MyHealthContext context, int tenantId)
        {
            var visits = new List<HomeAppointment>();

            var patients = context
                .Patients.OrderBy(p => p.PatientId).Select(p => p.PatientId)
                .Skip(1).Take(4).ToList();

            var doctors = context.Doctors.Select(p => p.DoctorId).ToList();

            foreach (int doctorId in doctors)
            {
                for (int i = 1; i <= AppointmentMonths; i++)
                {
                    var visit = new HomeAppointment
                    {
                        PatientId = patients[0],
                        DoctorId = doctorId,
                        DateTime = GetAppointmentDate(i),
                        Latitude = 40.721847,
                        Longitude = -74.007326,
                        Address = "48 Wall St, New York, NY 10037",
                        Visited = false,
                        TenantId = tenantId,
                        IsUrgent = true,
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        Id = Guid.NewGuid().ToString()
                    };
                    visits.Add(visit);

                    visit = new HomeAppointment
                    {
                        PatientId = patients[1],
                        DoctorId = doctorId,
                        DateTime = GetAppointmentDate(i),
                        Latitude = 40.721847,
                        Longitude = -74.007326,
                        Address = "Madison Ave 10037, New York, NY 10037",
                        Visited = false,
                        IsUrgent = false,
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        TenantId = tenantId,
                        Id = Guid.NewGuid().ToString()
                    };
                    visits.Add(visit);

                    visit = new HomeAppointment
                    {
                        PatientId = patients[0],
                        DoctorId = doctorId,
                        DateTime = GetAppointmentDate(i),
                        Latitude = 40.721847,
                        Longitude = -74.007326,
                        Address = "48 Wall St, New York, NY 10037",
                        Visited = true,
                        IsUrgent = false,
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        TenantId = tenantId,
                        Id = Guid.NewGuid().ToString()
                    };
                    visits.Add(visit);

                    visit = new HomeAppointment
                    {
                        PatientId = patients[1],
                        DoctorId = doctorId,
                        DateTime = GetAppointmentDate(i),
                        Latitude = 40.721847,
                        Longitude = -74.007326,
                        Address = "Madison Ave 10037, New York, NY 10037",
                        Visited = true,
                        IsUrgent = true,
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        TenantId = tenantId,
                        Id = Guid.NewGuid().ToString()
                    };
                    visits.Add(visit);

                    visit = new HomeAppointment
                    {
                        PatientId = patients[2],
                        DoctorId = doctorId,
                        DateTime = GetAppointmentDate(i),
                        Latitude = 40.721847,
                        Longitude = -74.007326,
                        Address = "48 Wall St, New York, NY 10037",
                        Visited = false,
                        IsUrgent = true,
                        TenantId = tenantId,
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        Id = Guid.NewGuid().ToString()
                    };
                    visits.Add(visit);

                    visit = new HomeAppointment
                    {
                        PatientId = patients[3],
                        DoctorId = doctorId,
                        DateTime = GetAppointmentDate(i),
                        Latitude = 40.721847,
                        Longitude = -74.007326,
                        Address = "Madison Ave 10037, New York, NY 10037",
                        IsUrgent = true,
                        Visited = false,
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        TenantId = tenantId,
                        Id = Guid.NewGuid().ToString()
                    };
                    visits.Add(visit);

                    visit = new HomeAppointment
                    {
                        PatientId = patients[2],
                        DoctorId = doctorId,
                        DateTime = GetAppointmentDate(i),
                        Latitude = 40.721847,
                        Longitude = -74.007326,
                        Address = "48 Wall St, New York, NY 10037",
                        Visited = true,
                        IsUrgent = false,
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        TenantId = tenantId,
                        Id = Guid.NewGuid().ToString()
                    };
                    visits.Add(visit);

                    visit = new HomeAppointment
                    {
                        PatientId = patients[3],
                        DoctorId = doctorId,
                        DateTime = GetAppointmentDate(i),
                        Latitude = 40.721847,
                        Longitude = -74.007326,
                        Address = "Madison Ave 10037, New York, NY 10037",
                        Visited = true,
                        IsUrgent = false,
                        Description = "Follow up in order to determine the effectiveness of treatment received",
                        TenantId = tenantId,
                        Id = Guid.NewGuid().ToString()
                    };
                    visits.Add(visit);
                }
            }

            context.HomeAppointments.AddRange(visits);
            context.SaveChanges();
        }
 public async Task UpdateAsync(HomeAppointment homeAppointment)
 {
     _context.HomeAppointments.Update(homeAppointment);
     await _context.SaveChangesAsync();
 }