public bool DeleteTherapist(MassageTherapists person) { try { var patientAppRecord = from appts in patientApptInformationDatabaseContext.PatientAppointmentInformations where appts.TherapistId == person.Id select appts; int count = patientAppRecord.Count <PatientAppointmentInformation>(); if (count == 0) { var therapistRecord = from therapist in therapistDatabaseContext.Therapists where therapist.Id == person.Id select therapist; therapistDatabaseContext.Therapists.DeleteOnSubmit(therapistRecord.Single <Therapist>()); therapistDatabaseContext.SubmitChanges(); return(true); } return(false); } catch (Exception ex) { return(false); } }
public void UpdateTherapist(MassageTherapists person) { MyTherapistEncryption.SecurityController dataEncryptionAlgo = new SecurityController(); bool newrecord = false; Therapist therapistRecord = null; try { var therapistQuery = from therapist in therapistDatabaseContext.Therapists where therapist.Id == person.Id select therapist; therapistRecord = therapistQuery.Single <Therapist>(); therapistRecord.Name = dataEncryptionAlgo.EncryptData(person.Name); therapistRecord.Password = dataEncryptionAlgo.EncryptData(person.Password); } catch (Exception ex) { newrecord = true; } if (newrecord) { therapistRecord = new Therapist(); therapistRecord.Id = Guid.NewGuid(); therapistRecord.Name = dataEncryptionAlgo.EncryptData(person.Name); therapistRecord.Password = dataEncryptionAlgo.EncryptData(person.Password); therapistDatabaseContext.Therapists.InsertOnSubmit(therapistRecord); } therapistDatabaseContext.SubmitChanges(); }
protected void btnSaveEditTherapist_Click(object sender, EventArgs e) { TherapistTableManager therapistTableManager = new TherapistTableManager(); DatabaseObjects.MassageTherapists therapist = null; if (Session[CommonDefinitions.CommonDefinitions.THERAPIST_ID] == null) { therapist = new DatabaseObjects.MassageTherapists(Guid.Empty); } else { therapist = new DatabaseObjects.MassageTherapists(Guid.Parse(Session[CommonDefinitions.CommonDefinitions.THERAPIST_ID].ToString())); } therapist.Name = txtBoxTherapistName.Text; therapist.Password = txtBoxTherapistPassword.Text; therapistTableManager.UpdateTherapist(therapist); Session[CommonDefinitions.CommonDefinitions.THERAPIST_ID] = null; if (TherapistUpdated != null) { TherapistUpdated(this, e); } }
public MassageTherapists FindTherapist(MassageTherapists person) { MassageTherapists massageTherapist = null; Therapist therapistRecord = null; if (person.Id != Guid.Empty) { try { var query = from therapist in therapistDatabaseContext.Therapists where therapist.Id == person.Id select therapist; therapistRecord = query.First <Therapist>(); massageTherapist = new MassageTherapists(therapistRecord.Id); MyTherapistEncryption.SecurityController dataEncryptionAlgo = new MyTherapistEncryption.SecurityController(); massageTherapist.Name = dataEncryptionAlgo.DecryptData(therapistRecord.Name); massageTherapist.Password = dataEncryptionAlgo.DecryptData(therapistRecord.Password); } catch (Exception ex) { ex.GetHashCode(); } } else { try { MyTherapistEncryption.SecurityController dataEnryptionAlgo = new SecurityController(); string encryptedName = dataEnryptionAlgo.EncryptData(person.Name); string encryptedPassword = dataEnryptionAlgo.EncryptData(person.Password); var query = from therapist in therapistDatabaseContext.Therapists where (therapist.Name == encryptedName && therapist.Password == encryptedPassword) select therapist; therapistRecord = query.First <Therapist>(); massageTherapist = new MassageTherapists(therapistRecord.Id); MyTherapistEncryption.SecurityController dataEncryptionAlgo = new MyTherapistEncryption.SecurityController(); massageTherapist.Name = dataEncryptionAlgo.DecryptData(therapistRecord.Name); massageTherapist.Password = dataEncryptionAlgo.DecryptData(therapistRecord.Password); } catch (Exception ex) { } } return(massageTherapist); }