Exemplo n.º 1
0
        public static CustomerArtistInt Convert(CustomerArtistIntDto customerArtistIntDto)
        {
            if (customerArtistIntDto == null)
            {
                return(null);
            }
            CustomerArtistInt customerArtistInt = new CustomerArtistInt();

            customerArtistInt.CustomerID = customerArtistIntDto.Customer.CustomerID.Value;
            customerArtistInt.ArtistID   = customerArtistIntDto.Artist.Id;
            return(customerArtistInt);
        }
Exemplo n.º 2
0
        //
        // CUSTOMER_ARTIST_INT
        //
        public static CustomerArtistIntDto Convert(CustomerArtistInt customerArtistInt)
        {
            if (customerArtistInt == null)
            {
                return(null);
            }
            CustomerArtistIntDto customerArtistIntDto = new CustomerArtistIntDto();

            customerArtistIntDto.Customer = Convert(DaoFactory.GetCustomerDao().Get(customerArtistInt.CustomerID));
            customerArtistIntDto.Artist   = Convert(DaoFactory.GetArtistDao().Get(customerArtistInt.ArtistID));
            return(customerArtistIntDto);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Загрузка id
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private static CustomerArtistInt LoadCustomerArtistInt(SqlDataReader reader)
        {
            //Создаём пустой объект
            CustomerArtistInt customerArtistInt = new CustomerArtistInt();
            //Заполняем поля объекта в соответствии с названиями полей результирующего
            // набора данных
            int cust = reader.GetOrdinal("CustomerID");
            int art  = reader.GetOrdinal("ArtistID");

            customerArtistInt.CustomerID = reader[cust] == DBNull.Value ? -1 : reader.GetInt32(cust);
            customerArtistInt.ArtistID   = reader[art] == DBNull.Value ? -1 : reader.GetInt32(art);
            return(customerArtistInt);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Обновить информацию о id
 /// </summary>
 /// <param name="customerArtistInt">id</param>
 public void Update(CustomerArtistInt customerArtistInt)
 {
     using (var conn = GetConnection())
     {
         conn.Open();
         using (var cmd = conn.CreateCommand())
         {
             cmd.CommandText = "UPDATE CUSTOMER_ARTIST_INT SET CustomerID = @CustomerID,ArtistID=@ArtistID WHERE ArtistID = @ID";
             cmd.Parameters.AddWithValue("@CustomerID", customerArtistInt.CustomerID);
             cmd.Parameters.AddWithValue("@ArtistID", customerArtistInt.ArtistID);
             cmd.ExecuteNonQuery();
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Добавить новый id
 /// </summary>
 /// <param name="customerArtistInt">id</param>
 public void Add(CustomerArtistInt customerArtistInt)
 {
     using (var conn = GetConnection())
     {
         conn.Open();
         using (var cmd = conn.CreateCommand())
         {
             cmd.CommandText = "INSERT INTO CUSTOMER_ARTIST_INT(CustomerID,ArtistID)VALUES(@CustomerID, @ArtistID)";
             cmd.Parameters.AddWithValue("@CustomerID", customerArtistInt.CustomerID);
             cmd.Parameters.AddWithValue("@ArtistID", customerArtistInt.ArtistID);
             cmd.ExecuteNonQuery();
         }
     }
 }