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; } } }
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(); } }