public static void BookDoctorByPatient(int doctorId, int patientID, ComboBox comboBox) { DoctorPatientDataContext dp = new DoctorPatientDataContext(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Arwin\documents\visual studio 2015\Projects\CSharpProjects\DoctorPatientPortal\DoctorPatient.mdf;Integrated Security=True;Connect Timeout=30"); DoctorBooking db = null; try { db = new DoctorBooking() { DrId = doctorId, PId = patientID, BookingTime = comboBox.Text, BookingDate = DateTime.Now.AddDays(1).ToShortDateString() }; dp.DoctorBookings.InsertOnSubmit(db); dp.SubmitChanges(); MessageBox.Show("Booked successfully", "Query Result"); }catch (Exception) { MessageBox.Show("Failed to set the time", "Query Result"); } }
public HttpResponseMessage UpdateBooking(DoctorBooking aBooking) { try { if (!ModelState.IsValid) { _response = Request.CreateResponse(HttpStatusCode.NotAcceptable); } _aClinicalXEntities.DoctorBookings.AddOrUpdate(aBooking); var b = _aClinicalXEntities.SaveChanges(); _response = Request.CreateResponse(HttpStatusCode.OK); } catch (Exception e) { _response = Request.CreateResponse(HttpStatusCode.BadRequest, e); } return(_response); }