Exemple #1
0
 public PracticeDTO Add(PracticeDTO practiceDTO)
 {
     using (_connection = new SqlConnection(_connectionString))
     {
         try
         {
             var        query      = "insert into Practice(Name,Address,Specialty) values (@name,@address,@specialty)";
             SqlCommand sqlCommand = new SqlCommand(query, _connection);
             sqlCommand.Parameters.AddWithValue("@name", practiceDTO.Name);
             sqlCommand.Parameters.AddWithValue("@address", practiceDTO.Address);
             sqlCommand.Parameters.AddWithValue("@specialty", practiceDTO.Specialty);
             _connection.Open();
             sqlCommand.ExecuteNonQuery();
             var practice = new Practices
             {
                 Name      = practiceDTO.Name,
                 Address   = practiceDTO.Address,
                 Specialty = practiceDTO.Specialty
             };
             return(PracticeToDTO(practice));
         }
         catch
         {
             throw;
         }
     }
 }
Exemple #2
0
 private static PracticeDTO PracticeToDTO(Practices practice) =>
 new PracticeDTO
 {
     ID        = practice.ID,
     Name      = practice.Name,
     Address   = practice.Address,
     Specialty = practice.Specialty
 };