public TreatmentRoomBO ConvertTrmtRmRecToBO(TreatmentRoom_Record treatmentRoom) { TreatmentRoomBO treatmentRoomBO = new TreatmentRoomBO(treatmentRoom.Room_ID, Convert.ToString(treatmentRoom.Timings), treatmentRoom.DateOfJoin, treatmentRoom.IsBooked, treatmentRoom.Patient_ID); return(treatmentRoomBO); }
//Method to convert BO to TreatmentRoom public Treatment_Room ConvertBOToTreatmentRoom(Treatment_Room treatmentRoom, TreatmentRoomBO treatmentRoomBO) { if (treatmentRoomBO.room_ID != null) { treatmentRoom.Room_ID = treatmentRoomBO.room_ID; } if (!string.IsNullOrEmpty(treatmentRoomBO.timings)) { treatmentRoom.Timings = TimeSpan.Parse(treatmentRoomBO.timings); } if (treatmentRoomBO.date != DateTime.MinValue) { treatmentRoom.DateOfJoin = treatmentRoomBO.date; } if (treatmentRoomBO.patient_ID != 0) { treatmentRoom.Patient_ID = treatmentRoomBO.patient_ID; } if (treatmentRoomBO.appointment_ID != 0) { treatmentRoom.Appointment_ID = treatmentRoomBO.appointment_ID; } treatmentRoom.IsBooked = treatmentRoomBO.isBooked; return(treatmentRoom); }
public TreatmentRoomBO InsertTreatmentRoomRec(TreatmentRoomBO treatmentRoomBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } TreatmentRoom_Record trmntRoom = new TreatmentRoom_Record(); objHmsDataContext.TreatmentRoom_Records.InsertOnSubmit(ConvertBOToTreatmentRoomRec(trmntRoom, treatmentRoomBO)); objHmsDataContext.SubmitChanges(); TreatmentRoom_Record newtrmntRoom = objHmsDataContext.TreatmentRoom_Records.SingleOrDefault(trmntroom => (trmntroom.Room_ID == treatmentRoomBO.room_ID && trmntroom.DateOfJoin == treatmentRoomBO.date)); return(ConvertTrmtRmRecToBO(newtrmntRoom)); } } catch (Exception e) { TreatmentRoomBO treatmentRoom_BO = new TreatmentRoomBO(); return(treatmentRoom_BO); } }
public TreatmentRoomBO CheckAvailabilityTreatmentRoom(TreatmentRoomBO treatmentRoomBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } Treatment_Room trmntRoom = new Treatment_Room(); // objHmsDataContext.Treatment_Rooms.InsertOnSubmit(ConvertBOToTreatmentRoom(trmntRoom, treatmentRoomBO)); //if (objHmsDataContext.Treatment_Rooms.Where(trmntroom => (trmntroom.Room_ID == treatmentRoomBO.room_ID && trmntroom.DateOfJoin == treatmentRoomBO.date && trmntroom.IsBooked == true)).FirstOrDefault()) //{ //} TreatmentRoomBO newtrmntRoom = objHmsDataContext.Treatment_Rooms.Where(trmntroom => (trmntroom.Room_ID == treatmentRoomBO.room_ID && trmntroom.DateOfJoin == treatmentRoomBO.date && trmntroom.IsBooked == true)).Select(t => new TreatmentRoomBO { timings = Convert.ToString(t.Timings) }).First(); return(newtrmntRoom); } } catch (Exception e) { return(null); } }
//Method to Delete TreatmentRoom record, wtih string as return type and treatment business object as parameter public string DeleteTreatmentRoom(TreatmentRoomBO treatmentRoomBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } Treatment_Room treatmentRoom = new Treatment_Room(); objHmsDataContext.Treatment_Rooms.DeleteOnSubmit(ConvertBOToTreatmentRoom(treatmentRoom, treatmentRoomBO)); objHmsDataContext.SubmitChanges(); return("TreatmentRoom details deleted Successfully"); } } catch (Exception e) { return("Unable to Delete treatmentRoom details please try again later"); } }
public IEnumerable <TreatmentRoomBO> UpdateTreatmentRoom(TreatmentRoomBO trmntBO) { TreatmentRoomBLLFactory trmntroomBLLFactory = new TreatmentRoomBLLFactory(); var result = trmntroomBLLFactory.CreateTreatmentRoomBLL().UpdateTreatmentRoomBLL().CreateTreatmentRoomDAL().UpdateTreatmentRoom(trmntBO); return(result); }
public string UpdateTreatmentRoom(TreatmentRoomBO trmntBO) { TreatmentRoomBLLFactory trmntroomBLLFactory = new TreatmentRoomBLLFactory(); string result = trmntroomBLLFactory.CreateTreatmentRoomBLL().UpdateTreatmentRoomBLL().CreateTreatmentRoomDAL().UpdateTreatmentRoom(trmntBO); return(result); }
public IEnumerable <TreatmentRoomBO> GetAvailableRooms(TreatmentRoomBO room) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } //List<TreatmentRoomBO> treatmentRoom = objHmsDataContext.TreatmentRoom_Records // .Where(t => (t.DateOfJoin != room.date && t.IsBooked == false)) // .Select(t => new TreatmentRoomBO //{ // patient_ID = t.Patient_ID, // timings = Convert.ToString(t.Timings), // isBooked = t.IsBooked, // date = t.DateOfJoin, // room_ID = t.Room_ID //}).ToList(); List <TreatmentRoomBO> treatmentRoomRec = objHmsDataContext.ExecuteQuery <TreatmentRoomBO>("SELECT Room_ID, Appointment_ID, DateOfJoin,IsBooked,Patient_ID FROM TreatmentRoom_Records WHERE Room_ID IN( SELECT MAX (Room_ID) FROM TreatmentRoom_Records GROUP BY Room_ID)").ToList(); List <TreatmentRoomBO> treatmentRoomRecRemove = new List <TreatmentRoomBO>(); List <TreatmentRoomBO> treatmentRoomRecRemoveNew = new List <TreatmentRoomBO>(); foreach (var r in treatmentRoomRec) { if (r.DateOfJoin == room.date) { treatmentRoomRecRemove.Add(r); } } foreach (var r in treatmentRoomRecRemove) { if (r.isBooked == true) { treatmentRoomRecRemoveNew.Add(r); } } foreach (var r in treatmentRoomRecRemoveNew) { treatmentRoomRec = treatmentRoomRec.Where(rr => rr.room_ID != r.room_ID).ToList(); //treatmentRoomRec = treatmentRoomRec.; } return(treatmentRoomRec); } } catch (Exception e) { IEnumerable <TreatmentRoomBO> trmntRoomBO = null; return(trmntRoomBO); } }
// DELETE: api/TreatmentRoom/5 //Delete action which accpets int as input parameter and string as return type public string Delete(string id) { TreatmentRoomBO treatmentRoomBO = new TreatmentRoomBO(); treatmentRoomBO.room_ID = id; TreatmentRoomBLLFactory trmntroomBLLFactory = new TreatmentRoomBLLFactory(); string result = trmntroomBLLFactory.CreateTreatmentRoomBLL().DeleteTreatmentRoomBLL().CreateTreatmentRoomDAL().DeleteTreatmentRoom(treatmentRoomBO); return(result); }
// GET: api/TreatmentRoom/5 //Get action which accepts int input parameter and treatment business object as return type public TreatmentRoomBO Get(string id) { TreatmentRoomBO treatmentRoomBO = new TreatmentRoomBO(); treatmentRoomBO.room_ID = id; TreatmentRoomBLLFactory trmntroomBLLFactory = new TreatmentRoomBLLFactory(); TreatmentRoomBO trmntBO = trmntroomBLLFactory.CreateTreatmentRoomBLL().GetTreatmentRoomBLL().CreateTreatmentRoomDAL().GetTreatmentRoom(treatmentRoomBO); return(trmntBO); }
//Method to update TreatmentRoom details, with string as return type and treatment business object as parameter public IEnumerable <TreatmentRoomBO> UpdateTreatmentRoom(TreatmentRoomBO treatmentRoomBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } Treatment_Room treatmentRoom = objHmsDataContext.Treatment_Rooms.Where(trmntRooms => (trmntRooms.Room_ID == treatmentRoomBO.room_ID && trmntRooms.Appointment_ID == treatmentRoomBO.appointment_ID)).FirstOrDefault(); if (treatmentRoom != null) { Treatment_Room updateTrmntRoom = ConvertBOToTreatmentRoom(treatmentRoom, treatmentRoomBO); } objHmsDataContext.SubmitChanges(); TreatmentRoom_Record tr = new TreatmentRoom_Record(); tr.Appointment_ID = treatmentRoomBO.appointment_ID; tr.DateOfJoin = treatmentRoomBO.date; tr.Patient_ID = treatmentRoomBO.patient_ID; tr.Room_ID = treatmentRoomBO.room_ID; //tr.Timings = treatmentRoomBO.timings; if (treatmentRoomBO.isBooked != false) { tr.IsBooked = true; } else { tr.IsBooked = false; } //objHmsDataContext.TreatmentRoom_Records.InsertOnSubmit(tr); objHmsDataContext.SubmitChanges(); UpdateTreatmentRoomRecord(tr); return(GetAllTreatmentRooms()); } } catch (Exception e) { IEnumerable <TreatmentRoomBO> room = null; return(room); } }
//Method to get TreatmentRoom details, with treatment business object as return type and treatment business object as parameter public TreatmentRoomBO GetTreatmentRoom(TreatmentRoomBO treatmentRoomBO) { try { using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString)) { if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed) { objHmsDataContext.Connection.Open(); } Treatment_Room treatmentRoom = objHmsDataContext.Treatment_Rooms.SingleOrDefault(trmntRoom => (trmntRoom.Room_ID == treatmentRoomBO.room_ID && trmntRoom.DateOfJoin == treatmentRoomBO.date)); return(ConvertTrmtRmToBO(treatmentRoom)); } } catch (Exception e) { TreatmentRoomBO trmntRoomBO = new TreatmentRoomBO(); return(trmntRoomBO); } }
public void InsertTreatmentRoomRec(TreatmentRoomBO treatmentRoomBO) { TreatmentRoomBLLFactory trmntroomBLLFactory = new TreatmentRoomBLLFactory(); TreatmentRoomBO trmntBO = trmntroomBLLFactory.CreateTreatmentRoomBLL().CreateTreatmentRoomBLL().CreateTreatmentRoomDAL().InsertTreatmentRoomRec(treatmentRoomBO); }
public TreatmentRoomBO CheckAvailabilityTreatmentRoom(TreatmentRoomBO roomBO) { TreatmentRoomBLLFactory trmntroomBLLFactory = new TreatmentRoomBLLFactory(); return(trmntroomBLLFactory.CreateTreatmentRoomBLL().DeleteTreatmentRoomBLL().CreateTreatmentRoomDAL().CheckAvailabilityTreatmentRoom(roomBO)); }
public IEnumerable <TreatmentRoomBO> GetAvailableRooms(TreatmentRoomBO trmntBO) { TreatmentRoomBLLFactory trmntroomBLLFactory = new TreatmentRoomBLLFactory(); return(trmntroomBLLFactory.CreateTreatmentRoomBLL().DeleteTreatmentRoomBLL().CreateTreatmentRoomDAL().GetAvailableRooms(trmntBO)); }