public AssignModel CallCheckingSecurityCodeMatch(string securityCode) { DoctorData doctorData = new DoctorData(); AssignDTO assignDTO = doctorData.CheckSecurityCodeMatch(securityCode); AssignModel assignModel; if (assignDTO.SecurityCodeMatch) { assignModel = new AssignModel { patientModel = new PatientModel { Id = assignDTO.patientDTO.Id }, SecurityCodeMatch = assignDTO.SecurityCodeMatch }; } else { assignModel = new AssignModel { SecurityCodeMatch = assignDTO.SecurityCodeMatch }; } return(assignModel); }
public AssignDTO CheckSecurityCodeMatch(string securityCode) { AssignDTO assignDTO = new AssignDTO(); using (ConnectionString connectionString = new ConnectionString()) { try { connectionString.sqlConnection.Open(); Microsoft.Data.SqlClient.SqlCommand cmd = new Microsoft.Data.SqlClient.SqlCommand("sp_Doctor_CheckSecurityCode", connectionString.sqlConnection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@securityCode", securityCode); using (Microsoft.Data.SqlClient.SqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { assignDTO = new AssignDTO { patientDTO = new PatientDTO { Id = reader.GetString(0) }, SecurityCodeMatch = true }; } else { assignDTO = new AssignDTO { SecurityCodeMatch = false }; } } } catch (Exception exception) { if (exception is InvalidCastException || exception is Microsoft.Data.SqlClient.SqlException) { Console.WriteLine("Error source: " + exception); throw; } } } return(assignDTO); }
public bool CheckExistingRelationDoctorPatient(string idD, string idP) { AssignDTO assignDTO = new AssignDTO(); using (ConnectionString connectionString = new ConnectionString()) { try { connectionString.sqlConnection.Open(); Microsoft.Data.SqlClient.SqlCommand cmd = new Microsoft.Data.SqlClient.SqlCommand("sp_Doctor_CheckExistingRelation", connectionString.sqlConnection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@idD", idD); cmd.Parameters.AddWithValue("@idP", idP); using (Microsoft.Data.SqlClient.SqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { assignDTO.ExistingRelation = true; } else { assignDTO.ExistingRelation = false; } } } catch (Exception exception) { if (exception is InvalidCastException || exception is Microsoft.Data.SqlClient.SqlException) { Console.WriteLine("Error source: " + exception); throw; } } } return(assignDTO.ExistingRelation); }