Пример #1
0
        public ServiceDeliveryDescription GetDeliveryDescriptionById(int deliveryId)
        {
            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();

                using (SqlCommand cmdGetDeliveryDescription = connection.CreateCommand())
                {
                    ServiceDeliveryDescription deliveryDescription = new ServiceDeliveryDescription();
                    cmdGetDeliveryDescription.CommandText = "SELECT deliveryId, name, address, zipCode, phoneNo, customerId FROM DeliveryDescription WHERE deliveryId = @deliveryId";
                    cmdGetDeliveryDescription.Parameters.AddWithValue("deliveryId", deliveryId);
                    SqlDataReader deliveryDescriptionReader = cmdGetDeliveryDescription.ExecuteReader();

                    while (deliveryDescriptionReader.Read())
                    {
                        deliveryDescription.DeliveryId = deliveryDescriptionReader.GetInt32(deliveryDescriptionReader.GetOrdinal("deliveryId"));
                        deliveryDescription.Name       = deliveryDescriptionReader.GetString(deliveryDescriptionReader.GetOrdinal("name"));
                        deliveryDescription.Address    = deliveryDescriptionReader.GetString(deliveryDescriptionReader.GetOrdinal("address"));
                        deliveryDescription.ZipCode    = deliveryDescriptionReader.GetInt32(deliveryDescriptionReader.GetOrdinal("zipCode"));
                        deliveryDescription.PhoneNo    = deliveryDescriptionReader.GetString(deliveryDescriptionReader.GetOrdinal("phoneNo"));
                        deliveryDescription.CustomerId = deliveryDescriptionReader.GetInt32(deliveryDescriptionReader.GetOrdinal("customerId"));
                    }
                    return(deliveryDescription);
                }
            }
        }
        public void TestInsertDeliveryDescription()
        {
            //Arrange
            DataDeliveryDescription    dataDeliveryDescription = new DataDeliveryDescription();
            ServiceDeliveryDescription deliveryDescription     = new ServiceDeliveryDescription();

            deliveryDescription.Name    = "Scheelsminde Hotel";
            deliveryDescription.Address = "Scheelsmindevej 35";
            deliveryDescription.ZipCode = 9200;
            deliveryDescription.PhoneNo = "12345678";
            //deliveryDescription.CustomerId = 100;
            bool check = false;

            //Act
            try
            {
                dataDeliveryDescription.InsertDeliveryDescription(deliveryDescription);
                check = true;
            }
            catch
            {
                check = false;
            }

            //Assert
            Assert.IsTrue(check);
        }
        public DeliveryDescription ConvertFromServiceDeliveryDescription(ServiceDeliveryDescription serviceDeliveryDescription)
        {
            DeliveryDescription deliveryDescriptionToReturn = new DeliveryDescription();

            deliveryDescriptionToReturn.DeliveryId = serviceDeliveryDescription.DeliveryId;
            deliveryDescriptionToReturn.Name       = serviceDeliveryDescription.Name;
            deliveryDescriptionToReturn.Address    = serviceDeliveryDescription.Address;
            deliveryDescriptionToReturn.ZipCode    = serviceDeliveryDescription.ZipCode;
            deliveryDescriptionToReturn.PhoneNo    = serviceDeliveryDescription.PhoneNo;
            deliveryDescriptionToReturn.CustomerId = serviceDeliveryDescription.CustomerId;

            return(deliveryDescriptionToReturn);
        }
        public ServiceDeliveryDescription ConvertToServiceDeliveryDescription(DeliveryDescription webshopDeliveryDescription)
        {
            ServiceDeliveryDescription deliveryDescriptionToReturn = new ServiceDeliveryDescription();

            deliveryDescriptionToReturn.DeliveryId = webshopDeliveryDescription.DeliveryId;
            deliveryDescriptionToReturn.Name       = webshopDeliveryDescription.Name;
            deliveryDescriptionToReturn.Address    = webshopDeliveryDescription.Address;
            deliveryDescriptionToReturn.ZipCode    = webshopDeliveryDescription.ZipCode;
            deliveryDescriptionToReturn.PhoneNo    = webshopDeliveryDescription.PhoneNo;
            deliveryDescriptionToReturn.CustomerId = webshopDeliveryDescription.CustomerId;

            return(deliveryDescriptionToReturn);
        }
Пример #5
0
        public void InsertDeliveryDescription(ServiceDeliveryDescription deliveryDescription)
        {
            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();

                using (SqlCommand cmdInsertDeliveryDescription = connection.CreateCommand())
                {
                    cmdInsertDeliveryDescription.CommandText = "INSERT INTO DeliveryDescription (name, address, zipCode, phoneNo, customerId) VALUES (@name, @address, @zipCode, @phoneNo, @customerId)";
                    cmdInsertDeliveryDescription.Parameters.AddWithValue("name", deliveryDescription.Name);
                    cmdInsertDeliveryDescription.Parameters.AddWithValue("address", deliveryDescription.Address);
                    cmdInsertDeliveryDescription.Parameters.AddWithValue("zipCode", deliveryDescription.ZipCode);
                    cmdInsertDeliveryDescription.Parameters.AddWithValue("phoneNo", deliveryDescription.PhoneNo);
                    cmdInsertDeliveryDescription.Parameters.AddWithValue("customerId", deliveryDescription.CustomerId);

                    cmdInsertDeliveryDescription.ExecuteNonQuery();
                }
            }
        }
Пример #6
0
        public int UpdateDeliveryDescription(ServiceDeliveryDescription deliveryDescription)
        {
            int rowsAffected;

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand cmdUpdateDeliveryDescription = connection.CreateCommand())
                {
                    cmdUpdateDeliveryDescription.CommandText = "UPDATE DeliveryDescription SET name = @name, address = @address, zipCode = @zipCode, phoneNo = @phoneNo, customerId = @customerId WHERE deliveryId = @deliveryId";
                    cmdUpdateDeliveryDescription.Parameters.AddWithValue("name", deliveryDescription.Name);
                    cmdUpdateDeliveryDescription.Parameters.AddWithValue("address", deliveryDescription.Address);
                    cmdUpdateDeliveryDescription.Parameters.AddWithValue("zipCode", deliveryDescription.ZipCode);
                    cmdUpdateDeliveryDescription.Parameters.AddWithValue("phoneNo", deliveryDescription.PhoneNo);
                    cmdUpdateDeliveryDescription.Parameters.AddWithValue("customerId", deliveryDescription.CustomerId);
                    cmdUpdateDeliveryDescription.Parameters.AddWithValue("deliveryId", deliveryDescription.DeliveryId);

                    rowsAffected = cmdUpdateDeliveryDescription.ExecuteNonQuery();
                }
            }
            return(rowsAffected);
        }
Пример #7
0
 public void UpdateDeliveryDescription(ServiceDeliveryDescription deliveryDescription)
 {
     deliveryDescriptionControl.UpdateDeliveryDescription(deliveryDescription);
 }
Пример #8
0
 public void InsertDeliveryDescription(ServiceDeliveryDescription deliveryDescription)
 {
     deliveryDescriptionControl.InsertDeliveryDescription(deliveryDescription);
 }
Пример #9
0
 public void UpdateDeliveryDescription(ServiceDeliveryDescription deliveryDescription)
 {
     dataDeliveryDescription.UpdateDeliveryDescription(deliveryDescription);
 }
Пример #10
0
        public ServiceDeliveryDescription GetDeliveryDescriptionById(int deliveryId)
        {
            ServiceDeliveryDescription deliveryDescription = dataDeliveryDescription.GetDeliveryDescriptionById(deliveryId);

            return(deliveryDescription);
        }
Пример #11
0
 public void InsertDeliveryDescription(ServiceDeliveryDescription deliveryDescription)
 {
     dataDeliveryDescription.InsertDeliveryDescription(deliveryDescription);
 }