public T Get(int id) { using (CaremeDBContext entityContext = new CaremeDBContext()) { return(GetEntity(entityContext, id)); } }
public ScheduleController() { dbContext = new CaremeDBContext(); scheduleRepo = new ScheduleDataRepository(dbContext); // scheduleRepo = new ScheduleRepository(dbContext); doctorRepo = new DoctorRepository(dbContext); }
public DomainController() { dbContext = new CaremeDBContext(); repo = new DomainRepository(dbContext); serviceRepo = new ServiceRepository(dbContext); procedureRepo = new ProcedureRepository(dbContext); }
public HospitalController(IPhoto iPhoto) { this.iPhoto = iPhoto; dbContext = new CaremeDBContext(); hospitalRepo = new HospitalRepository(dbContext); docHosRepo = new DoctorHospitalRepository(dbContext); }
public int Remove(T entity) { using (CaremeDBContext entityContext = new CaremeDBContext()) { entityContext.Entry <T>(entity).State = EntityState.Deleted; return(entityContext.SaveChanges()); } }
public int Update(T entity) { using (CaremeDBContext entityContext = new CaremeDBContext()) { entityContext.Entry <T>(entity).State = EntityState.Modified; return(entityContext.SaveChanges()); } }
public FAQController() { CaremeDBContext dbContext = new CaremeDBContext(); repo = new FAQRepository(dbContext); serviceRepo = new ServiceRepository(dbContext); procedureRepo = new ProcedureRepository(dbContext); }
public BookingController() { dbContext = new CaremeDBContext(); scheduleRepo = new ScheduleRepository(dbContext); hospitalRepo = new HospitalRepository(dbContext); doctorRepo = new DoctorRepository(dbContext); appointmentRepo = new AppointmentRepository(dbContext); }
public PatientController(IBookingService iBookingService) { this.iBookingService = iBookingService; dbContext = new CaremeDBContext(); patientRepo = new PatientRepository(dbContext); appRepo = new AppointmentRepository(dbContext); docRepo = new DoctorRepository(dbContext); }
public HomeController(IScheduleService iScheduleService) { this.iScheduleService = iScheduleService; dbContext = new CaremeDBContext(); scheduleRepo = new ScheduleRepository(dbContext); hospitalRepo = new HospitalRepository(dbContext); doctorRepo = new DoctorRepository(dbContext); appointmentRepo = new AppointmentRepository(dbContext); }
public ScheduleController(IScheduleService iScheduleService, IScheduleDelService iScheduleDelService) { this.iScheduleDelService = iScheduleDelService; this.iScheduleService = iScheduleService; dbContext = new CaremeDBContext(); scheduleRepo = new ScheduleRepository(dbContext); hospitalRepo = new HospitalRepository(dbContext); scheduleDataRepo = new ScheduleDataRepository(dbContext); }
public DoctorController(IPhoto iPhoto, IQueryService iQueryService) { this.iPhoto = iPhoto; this.iQueryService = iQueryService; dbContext = new CaremeDBContext(); doctorRepo = new DoctorRepository(dbContext); doctorhospitalRepo = new DoctorHospitalRepository(dbContext); scheduleRepo = new ScheduleRepository(dbContext); scheduledataRepo = new ScheduleDataRepository(dbContext); }
public PatientController(IPhoto iPhoto, IQueryService iQueryService) { this.iPhoto = iPhoto; this.iQueryService = iQueryService; dbContext = new CaremeDBContext(); scheduleRepo = new ScheduleRepository(dbContext); hospitalRepo = new HospitalRepository(dbContext); doctorRepo = new DoctorRepository(dbContext); appointmentRepo = new AppointmentRepository(dbContext); }
public int Add(T entity) { int result = 0; using (CaremeDBContext entityContext = new CaremeDBContext()) { var obj = AddEntity(entityContext, entity); result = entityContext.SaveChanges(); } return(result); }
protected override tbAccount AddOrUpdateEntity(CaremeDBContext entityContext, tbAccount entity) { if (entity.ID == default(int)) { return(entityContext.tbAccounts.Add(entity)); } else { return(entityContext.tbAccounts.FirstOrDefault(e => e.ID == entity.ID)); } }
public T UpdatewithObj(T entity) { using (CaremeDBContext entityContext = new CaremeDBContext()) { entityContext.Entry <T>(entity).State = EntityState.Modified; if (entityContext.SaveChanges() > 0) { return(entity); } return(null); } }
public T AddWithGetObj(T entity) { using (CaremeDBContext entityContext = new CaremeDBContext()) { var obj = AddEntity(entityContext, entity); if (entityContext.SaveChanges() > 0) { return(obj); } } return(null); }
//public NotiTimeFrameViewModel scheduleNotis(DateTime date, int doctorid, string TimeFrame) //{ // using(var ctx = new CaremeDBContext()) // { // var day = date.DayOfWeek.ToString(); // DateTime? combined = null; // List<tbSchedule> schedules = ctx.tbSchedules.Where(a => a.IsDeleted != true // && a.DoctorID == doctorid).Where(daysQuery(day)).ToList(); // List<NotiViewModel> NotiList = new List<NotiViewModel>(); // foreach (var item in schedules) // { // combined = HelperExtension.getCombinedDateTime(date, item.Fromtime); // var appointments = ctx.tbAppointments.Where(a => a.IsDeleted != true // && a.DoctorId == item.DoctorID // && a.HospitalId == item.HospitalID && a.Day == day // && a.AppointmentDateTime == combined); // NotiViewModel notiMD = new NotiViewModel(); // notiMD.scheduleID = item.ID; // notiMD.AppointmentDateTime = combined ?? date; // notiMD.hospitalID = item.HospitalID ?? 0; // notiMD.hospitalName = item.HospitalName; // notiMD.patientCount = appointments.Count(); // if (notiMD.patientCount > 0) // { // notiMD.LastActivtBookedTime = appointments.OrderByDescending(a => a.Accesstime) // .FirstOrDefault().Accesstime ?? date; // } // NotiList.Add(notiMD); // } // NotiTimeFrameViewModel NotiObj = new NotiTimeFrameViewModel(); // if(schedules.Count > 0) // { // NotiObj.NotiList = NotiList; // NotiObj.Timeframe = TimeFrame; // } // return NotiObj; // } //} public NotiTimeFrameViewModel scheduleNotis(DateTime date, int doctorid, string TimeFrame) { using (var ctx = new CaremeDBContext()) { date = date.Date; var day = date.DayOfWeek.ToString(); DateTime?combined = null; //List<tbSchedule> schedules = ctx.tbSchedules.Where(a => a.IsDeleted != true // && a.DoctorID == doctorid).Where(daysQuery(day)).ToList(); var dateto = date.AddDays(1).Date; List <tbScheduleData> schedules = ctx.tbScheduleDatas.Where(a => a.IsDeleted != true && a.DoctorID == doctorid && a.AppointmentDatetime >= date && a.AppointmentDatetime <= dateto).ToList(); List <NotiViewModel> NotiList = new List <NotiViewModel>(); foreach (var item in schedules) { //combined = HelperExtension.getCombinedDateTime(date, item.Fromtime); var appointments = ctx.tbAppointments.Where(a => a.IsDeleted != true && a.DoctorId == item.DoctorID && a.HospitalId == item.HospitalID && a.AppointmentDateTime == item.AppointmentDatetime); NotiViewModel notiMD = new NotiViewModel(); notiMD.scheduleID = item.ID; notiMD.AppointmentDateTime = item.AppointmentDatetime ?? date; notiMD.hospitalID = item.HospitalID ?? 0; notiMD.hospitalName = item.HospitalName; notiMD.patientCount = appointments.Count(); notiMD.MaxPatientCount = item.MaxPatientCount ?? 0; notiMD.IsLimited = item.IsLimited; notiMD.IsStopped = item.IsStopped; if (notiMD.patientCount > 0) { notiMD.LastActivtBookedTime = appointments.OrderByDescending(a => a.Accesstime) .FirstOrDefault().Accesstime ?? date; } NotiList.Add(notiMD); } NotiTimeFrameViewModel NotiObj = new NotiTimeFrameViewModel(); if (schedules.Count > 0) { NotiObj.NotiList = NotiList; NotiObj.Timeframe = TimeFrame; } return(NotiObj); } }
//public CountInTimeFrame hospitalSchedulesWithPatient(DateTime date, string TimeFrame, // int doctorid) //{ // using (CaremeDBContext context = new CaremeDBContext()) // { // DateTime scheduledate = date; // var day = scheduledate.DayOfWeek.ToString(); // CountInTimeFrame citf_data = new CountInTimeFrame(); // citf_data.TimeFrame = TimeFrame; // DateTime? combined = null; // List<tbSchedule> schedules = context.tbSchedules.Where(a => a.IsDeleted != true // && a.DoctorID == doctorid).Where(daysQuery(day)).ToList(); //date // List<HospitalListViewModel> hlistvm = new List<HospitalListViewModel>(); // foreach (var item in schedules) // { // var newdate = scheduledate.ToShortDateString();//tochange // var time = item.Fromtime.Value.ToShortTimeString(); // combined = DateTime.Parse(newdate + " " + time); // HospitalListViewModel hlvm = new HospitalListViewModel(); // hlvm.fromTime = item.Fromtime; // hlvm.toTime = item.Totime; // hlvm.patientCount = context.tbAppointments.Where(a => a.IsDeleted != true // && a.DoctorId == item.DoctorID // && a.HospitalId == item.HospitalID && a.Day == day && a.AppointmentDateTime == combined).Count(); // hlvm.hospitalId = item.HospitalID; // hlvm.hospitalName = item.HospitalName; // hlvm.appointmentDateTime = combined; // hlvm.scheduleID = item.ID; // hlistvm.Add(hlvm); // } // citf_data.hospitalList = hlistvm; // var nextday = date.AddDays(1).Date; // citf_data.totalPatientCount = context.tbAppointments.Where(a => a.IsDeleted != true).Where(a => a.DoctorId == doctorid // && a.Day == day && a.AppointmentDateTime >= date.Date && a.AppointmentDateTime <= nextday).Count(); // return citf_data; // } //} public CountInTimeFrame hospitalSchedulesWithPatient(DateTime date, string TimeFrame, int doctorid) { using (CaremeDBContext context = new CaremeDBContext()) { DateTime scheduledate = date; var day = scheduledate.DayOfWeek.ToString(); CountInTimeFrame citf_data = new CountInTimeFrame(); citf_data.TimeFrame = TimeFrame; DateTime?combined = null; //List<tbSchedule> schedules = context.tbSchedules.Where(a => a.IsDeleted != true // && a.DoctorID == doctorid).Where(daysQuery(day)).ToList(); //date date = date.Date; var dateto = date.AddDays(1); List <tbScheduleData> schedules = context.tbScheduleDatas.Where(a => a.IsDeleted != true && a.DoctorID == doctorid && a.AppointmentDatetime >= date && a.AppointmentDatetime <= dateto).ToList(); List <HospitalListViewModel> hlistvm = new List <HospitalListViewModel>(); foreach (var item in schedules) { //var newdate = scheduledate.ToShortDateString();//tochange //var time = item.Fromtime.Value.ToShortTimeString(); //combined = DateTime.Parse(newdate + " " + time); HospitalListViewModel hlvm = new HospitalListViewModel(); hlvm.fromTime = item.Fromtime; hlvm.toTime = item.Totime; hlvm.patientCount = context.tbAppointments.Where(a => a.IsDeleted != true && a.DoctorId == item.DoctorID && a.HospitalId == item.HospitalID && a.AppointmentDateTime == item.AppointmentDatetime).Count(); hlvm.hospitalId = item.HospitalID; hlvm.hospitalName = item.HospitalName; hlvm.appointmentDateTime = item.AppointmentDatetime; hlvm.scheduleID = item.ID; hlistvm.Add(hlvm); } citf_data.hospitalList = hlistvm; var nextday = date.AddDays(1).Date; citf_data.totalPatientCount = context.tbAppointments.Where(a => a.IsDeleted != true).Where(a => a.DoctorId == doctorid && a.AppointmentDateTime >= date.Date && a.AppointmentDateTime <= nextday).Count(); return(citf_data); } }
public T AddWithGetObj(T entity) { try { using (CaremeDBContext entityContext = new CaremeDBContext()) { var obj = AddEntity(entityContext, entity); if (entityContext.SaveChanges() > 0) { return(obj); } } return(null); } catch (Exception ex) { var x = ex; return(null); } }
public bool checkBookingAvailable(int ScheduleDataID) { var result = false; var Now = MyExtension.getLocalTime(DateTime.UtcNow); using (var ctx = new CaremeDBContext()) { var scheduledata = ctx.tbScheduleDatas.Where(a => a.IsDeleted != true && a.ID == ScheduleDataID && a.IsStopped != true && a.IsCancelled != true).FirstOrDefault(); if (scheduledata != null) { if (scheduledata.AppointmentDatetime > Now) { int reachedPTCount = scheduledata.ReachedPatientCount ?? 0; int maxPTCount = scheduledata.MaxPatientCount ?? 0; int count = maxPTCount - reachedPTCount; if (count > 0) { result = true; } else { result = false; } } else { result = false; } } else { result = false; } } return(result); }
public HttpResponseMessage getData(HttpRequestMessage request, int doctorid = 0) { DoctorHomeViewModel homeObj = new DoctorHomeViewModel(); homeObj.doctorid = doctorid; homeObj.doctorName = doctorRepo.GetWithoutTracking().Where(a => a.ID == doctorid).Select(a => a.Name).FirstOrDefault(); DateTime localNow = MyExtension.getLocalTime(DateTime.UtcNow); using (CaremeDBContext context = new CaremeDBContext()) { string timeFrame_Today = "Today"; DateTime today = MyExtension.getLocalTime(DateTime.UtcNow); CountInTimeFrame today_Count = iScheduleService.hospitalSchedulesWithPatient(today, timeFrame_Today, doctorid); string timeFrame_Tomorrow = "Tomorrow"; DateTime tomorrow = today.AddDays(1); CountInTimeFrame tomorrow_Count = iScheduleService.hospitalSchedulesWithPatient(tomorrow, timeFrame_Tomorrow, doctorid); DateTime DFtomorrow = today.AddDays(2); string timeFrame_DFTomorrow = DFtomorrow.Day + " " + DFtomorrow.ToString("MMM"); CountInTimeFrame DFtomorrow_Count = iScheduleService.hospitalSchedulesWithPatient(DFtomorrow, timeFrame_DFTomorrow, doctorid); DateTime TDFtomorrow = today.AddDays(3); string timeFrame_TDFTomorrow = TDFtomorrow.Day + " " + TDFtomorrow.ToString("MMM"); CountInTimeFrame TDFtomorrow_Count = iScheduleService.hospitalSchedulesWithPatient(TDFtomorrow, timeFrame_TDFTomorrow, doctorid); List <CountInTimeFrame> countInTimeframes = new List <CountInTimeFrame>(); countInTimeframes.Add(today_Count); countInTimeframes.Add(tomorrow_Count); countInTimeframes.Add(DFtomorrow_Count); countInTimeframes.Add(TDFtomorrow_Count); homeObj.CountList = countInTimeframes; return(request.CreateResponse <DoctorHomeViewModel>(HttpStatusCode.OK, homeObj)); } }
protected override tbAccount GetEntity(CaremeDBContext entityContext, int id) { return(entityContext.tbAccounts.FirstOrDefault(e => e.ID == id)); }
protected override tbAccount UpdateEntity(CaremeDBContext entityContext, tbAccount entity) { return(entityContext.tbAccounts.FirstOrDefault(e => e.ID == entity.ID)); }
protected override tbAccount AddEntity(CaremeDBContext entityContext, tbAccount entity) { return(entityContext.tbAccounts.Add(entity)); }
public AccountRepository(CaremeDBContext context) { this.entityContext = context; }
protected override tbDoctorHospital GetEntity(CaremeDBContext entityContext, int id) { return(entityContext.tbDoctorHospitals.FirstOrDefault(e => e.ID == id)); }
protected override tbDoctorHospital UpdateEntity(CaremeDBContext entityContext, tbDoctorHospital entity) { return(entityContext.tbDoctorHospitals.FirstOrDefault(e => e.ID == entity.ID)); }
protected override tbDoctorHospital AddEntity(CaremeDBContext entityContext, tbDoctorHospital entity) { return(entityContext.tbDoctorHospitals.Add(entity)); }
public DoctorHospitalRepository(CaremeDBContext context) { this.entityContext = context; }