public void UpdateDoctorInEF(UserDoctor docModel, Int32 userID) { using (var dbContext = new HealthcareDBEntities()) { //var author = .Authors.First(a => a.AuthorId == 1); var doctor = dbContext.UserDoctors.First(r => r.UserID == userID && r.DoctorID == docModel.DoctorID); doctor.FirstName = docModel.FirstName; doctor.LastName = docModel.LastName; doctor.EmailID = docModel.EmailID; doctor.RelatedHostpital = docModel.RelatedHostpital; doctor.Specialty = docModel.Specialty; doctor.Address = docModel.Address; doctor.ContactNumber1 = docModel.ContactNumber1; doctor.ContactNumber2 = docModel.ContactNumber2; doctor.PrimaryDoctorMark = docModel.PrimaryDoctorMark; try { dbContext.SaveChanges(); } catch (DbEntityValidationException e) { throw; } } }
//Update Hospital public void UpdateHospitalDetailsEF(HospitalForTableModel hospital) { using (var dbContext = new HealthcareDBEntities()) { var hos = dbContext.UserHospitals.First(r => r.UserID == hospital.UserID && r.HospitalID == hospital.HospitalID); hos.HospitalID = hospital.HospitalID; hos.HospitalName = hospital.HospitalName; hos.EmailID = hospital.EmailID; hos.Address = hospital.Address; hos.ContactNumber1 = hospital.Contact1; hos.ContactNumber2 = hospital.Contact2; hos.PrimaryMark = hospital.PrimaryMark; hos.UserID = hospital.UserID; try { dbContext.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } } }
//Deleting Doctor Details from DB public void DeleteDoctorDetailsEF(Int32 doctorID, Int32 userID) { using (var dbContext = new HealthcareDBEntities()) { var doc = dbContext.UserDoctors.Where(r => r.DoctorID == doctorID && r.UserID == userID).First(); dbContext.UserDoctors.Remove(doc); dbContext.SaveChanges(); } }
//Update Profile Picture in Database public void UpdateProfilePictureEF(Int32 userID, string url) { using (var dbContext = new HealthcareDBEntities()) { var userDetails = dbContext.ProfilePictures.First(r => r.UserID == userID); userDetails.PictureURL = url; dbContext.SaveChanges(); } }
//Update password public void UpdatePasswordEF(Int32 userID, string password) { using (var dbContext = new HealthcareDBEntities()) { var userDetails = dbContext.UserCredentials.First(r => r.UserID == userID); userDetails.Password = password; dbContext.SaveChanges(); } }
public void UpdateEmailVerificationEF(string email) { using (var dbContext = new HealthcareDBEntities()) { var emailUpdate = dbContext.EmailVerifications.First(r => r.EmailID == email); emailUpdate.VarificationStatus = "verified"; dbContext.SaveChanges(); } }
//Adition User Details public void UpdateAdditionalUserDetailsEF(Int32 userID, string address, Int64 phone) { using (var dbContext = new HealthcareDBEntities()) { var userDetails = dbContext.AdditionalUserDetails.First(r => r.UserID == userID); userDetails.Address = address; userDetails.PhoneNumber = phone; dbContext.SaveChanges(); } }
//Update User public void UpdateUserDetailsInCredentialEF(Int32 userID, string firstName, string lastName) { using (var dbContext = new HealthcareDBEntities()) { var userDetails = dbContext.UserCredentials.First(r => r.UserID == userID); userDetails.FirstName = firstName; userDetails.LastName = lastName; dbContext.SaveChanges(); } }
public void InsertProfilePictureEF(Int32 userID, string url) { using (var dbContext = new HealthcareDBEntities()) { var profile = new ProfilePicture { UserID = userID, PictureURL = url }; dbContext.ProfilePictures.Add(profile); dbContext.SaveChanges(); } }
//Additional User Details public void AdditionalUserDetailsEF(Int32 userID) { using (var dbContext = new HealthcareDBEntities()) { var addtional = new AdditionalUserDetail { UserID = userID, Address = null, PhoneNumber = null }; dbContext.AdditionalUserDetails.Add(addtional); dbContext.SaveChanges(); } }
//Verification State public void SetVerificationKeyEF(string email, string status, string code) { using (var dbContext = new HealthcareDBEntities()) { var verificationKey = new EmailVerification { EmailID = email, VarificationStatus = status, ActivationCode = code }; dbContext.EmailVerifications.Add(verificationKey); dbContext.SaveChanges(); } }
//Setting User Data public void SetUserDataEF(UserDetailsModel UDModel) { using (var dbContext = new HealthcareDBEntities()) { var newUserDetails = new UserCredential { UserID = UDModel.userId, FirstName = UDModel.firstName, LastName = UDModel.lastName, EmailID = UDModel.email, Password = UDModel.password }; dbContext.UserCredentials.Add(newUserDetails); dbContext.SaveChanges(); } }
public void AddNewReportEF(ReportModel report) { using (var dbContext = new HealthcareDBEntities()) { var newReport = new UserReport { ReportID = report.reportID, ReportType = report.reportType, Date = report.date, Hospital = report.hospital, Doctor = report.doctor, FileURL = report.upload, UserID = report.userID }; dbContext.UserReports.Add(newReport); dbContext.SaveChanges(); } }
public void AddNewHositalEF(HospitalDetailsModel hospital) { using (var dbContext = new HealthcareDBEntities()) { var newHospital = new UserHospital { HospitalID = hospital.hospitalID, HospitalName = hospital.hospitalName, Address = hospital.address, EmailID = hospital.emailID, ContactNumber1 = hospital.contact1, ContactNumber2 = hospital.contact2, PrimaryMark = hospital.primaryMark, UserID = hospital.userID }; dbContext.UserHospitals.Add(newHospital); dbContext.SaveChanges(); } }
public void AddNewDoctorEF(DoctorDetailsModel docModel) { using (var dbContext = new HealthcareDBEntities()) { var newDoctor = new UserDoctor { DoctorID = docModel.doctorID, FirstName = docModel.firstName, LastName = docModel.lastName, EmailID = docModel.email, RelatedHostpital = docModel.relatedHospital, Specialty = docModel.specialty, Address = docModel.address, ContactNumber1 = docModel.contactNumber1, ContactNumber2 = docModel.contactNumber2, PrimaryDoctorMark = docModel.primaryDoctorMark, UserID = docModel.userID }; dbContext.UserDoctors.Add(newDoctor); dbContext.SaveChanges(); } }