/*查看当前时间段多少人选择*/ public AllAppointmentEntity GetMyAppointment() { if (confirmed == false) { AllAppointmentEntity allAppointmentEntity = new AllAppointmentEntity(); allAppointmentEntity.ErrorMessage = "311 Not Logged in Yet! @Logic"; return allAppointmentEntity; } else { return doctorDAO.GetMyAppointment(confirmedDoctorID); } }
/*翻译AllAppointment的Entity为对应的数据契约*/ private void TranslateAllAppointmentEntityToAllAppointmentContractData( AllAppointmentEntity allAppointmentEntity, AllAppointment allAppointment) { allAppointment.ErrorMessage = allAppointmentEntity.ErrorMessage; allAppointment.Count = allAppointmentEntity.Count; allAppointment.appointment = new Appointment[allAppointment.Count]; for (int i = 0; i < allAppointment.Count; i++) { allAppointment.appointment[i] = new Appointment(); allAppointment.appointment[i].sGuid = allAppointmentEntity.appointment[i].gGuid.ToString(); allAppointment.appointment[i].Date = allAppointmentEntity.appointment[i].Date; allAppointment.appointment[i].UserID = allAppointmentEntity.appointment[i].UserID; allAppointment.appointment[i].DoctorID = allAppointmentEntity.appointment[i].DoctorID; allAppointment.appointment[i].Rank = allAppointmentEntity.appointment[i].Rank; allAppointment.appointment[i].Finished = allAppointmentEntity.appointment[i].Finished; } }
/*查看当前时间段多少人选择*/ public AllAppointmentEntity GetMyAppointment(string doctorID) { AllAppointmentEntity allAppointmentEntity = new AllAppointmentEntity(); DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities(); Doctor doctor = (from d in DEntities.Doctors where d.DoctorID == doctorID select d).FirstOrDefault(); if (doctor == null) { allAppointmentEntity.ErrorMessage = "312 Invalid DoctorID! @Data"; return allAppointmentEntity; } DateTime newDate = DateTime.Now; DateTime bedTime = newDate.Date; if (newDate.CompareTo(bedTime.AddHours(12)) >= 0) { bedTime = bedTime.AddHours(12); } var appointments = (from ap in DEntities.Appointments where (ap.DoctorID == doctorID) && (ap.Date == bedTime) orderby ap.Rank select ap); int appointmentCount = appointments.Count(); allAppointmentEntity.Count = appointmentCount; if (appointmentCount <= 0) { allAppointmentEntity.ErrorMessage = "313 No Appointment! @Data"; } else { allAppointmentEntity.appointment = new AppointmentEntity[appointmentCount]; int cnt = 0; foreach (var app in appointments) { allAppointmentEntity.appointment[cnt] = new AppointmentEntity(); allAppointmentEntity.appointment[cnt].gGuid = app.AppointmentID; allAppointmentEntity.appointment[cnt].UserID = app.UserID; allAppointmentEntity.appointment[cnt].DoctorID = app.DoctorID; allAppointmentEntity.appointment[cnt].Date = app.Date; allAppointmentEntity.appointment[cnt].Rank = app.Rank; if (app.Status == null) { allAppointmentEntity.appointment[cnt].Finished = false; } else { allAppointmentEntity.appointment[cnt].Finished = true; } cnt++; } } return allAppointmentEntity; }
/*获取待去的预约记录*/ public AllAppointmentEntity GetMyFutureAppointment() { if (confirmed == false) { AllAppointmentEntity allAppointmentEntity = new AllAppointmentEntity(); allAppointmentEntity.ErrorMessage = "432 Not Logged in Yet! @Logic"; return allAppointmentEntity; } else { return userDAO.GetMyFutureAppointment(confirmedUserID); } }