Пример #1
0
        public string SelectIdNeedCoach(string firstName, string lastName)
        {
            var result = _coachDao.SelectIdNeedCoach(firstName, lastName).ToList();

            if (result.Any())
            {
                return(result.FirstOrDefault().ToString());
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
 public void AddClient(Client client)
 {
     using (SqlConnection connection = new SqlConnection(connectionstring))
     {
         SqlCommand cmd = new SqlCommand("AddClient", connection);
         cmd.CommandType = System.Data.CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@firstName", client.FirstName);
         cmd.Parameters.AddWithValue("@lastName", client.LastName);
         cmd.Parameters.AddWithValue("@telephoneNumber", client.TelephoneNumber);
         if (client.FirstNameOfFavoriteCoach != null && client.LastNameOfFavoriteCoach != null)
         {
             cmd.Parameters.AddWithValue("@idFavoriteCoach", coachDao.SelectIdNeedCoach(client.FirstNameOfFavoriteCoach, client.LastNameOfFavoriteCoach));
         }
         connection.Open();
         cmd.ExecuteNonQuery();
     }
 }