Пример #1
0
        public ProductLine ConvertFromServiceProductLine(ServiceProductLine serviceProductLine)
        {
            ProductLine productLineToReturn = new ProductLine();

            productLineToReturn.ProductLineId = serviceProductLine.ProductLineId;
            productLineToReturn.Amount        = serviceProductLine.Amount;
            productLineToReturn.SubTotal      = serviceProductLine.SubTotal;
            productLineToReturn.OrderId       = serviceProductLine.OrderId;
            productLineToReturn.Product       = ConvertFromServiceProduct(serviceProductLine.Product);

            return(productLineToReturn);
        }
Пример #2
0
        public ServiceProductLine ConvertToServiceProductLine(ProductLine webshopProductLine)
        {
            ServiceProductLine productLineToReturn = new ServiceProductLine();

            productLineToReturn.ProductLineId = webshopProductLine.ProductLineId;
            productLineToReturn.Amount        = webshopProductLine.Amount;
            productLineToReturn.SubTotal      = webshopProductLine.SubTotal;
            productLineToReturn.OrderId       = webshopProductLine.OrderId;
            productLineToReturn.Product       = ConvertToServiceProduct(webshopProductLine.Product);

            return(productLineToReturn);
        }
Пример #3
0
        public void InsertProductLine(ServiceProductLine serviceProductLine)
        {
            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand cmdInsertProductLine = connection.CreateCommand())
                {
                    cmdInsertProductLine.CommandText = "INSERT INTO ProductLine (amount, subTotal, orderId, productId) VALUES (@amount, @subTotal, @orderId, @productId)";
                    cmdInsertProductLine.Parameters.AddWithValue("amount", serviceProductLine.Amount);
                    cmdInsertProductLine.Parameters.AddWithValue("subTotal", serviceProductLine.SubTotal);
                    cmdInsertProductLine.Parameters.AddWithValue("orderId", serviceProductLine.OrderId);
                    cmdInsertProductLine.Parameters.AddWithValue("productId", serviceProductLine.Product.ProductId);

                    cmdInsertProductLine.ExecuteNonQuery();
                }
            }
        }
Пример #4
0
        public int UpdateProductLine(ServiceProductLine serviceProductLine)
        {
            int rowsAffected;

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand cmdUpdateProductLine = connection.CreateCommand())
                {
                    cmdUpdateProductLine.CommandText = "UPDATE ProductLine SET amount = @amount, subTotal = @subTotal WHERE productLineId = @productLineId";
                    cmdUpdateProductLine.Parameters.AddWithValue("amount", serviceProductLine.Amount);
                    cmdUpdateProductLine.Parameters.AddWithValue("subTotal", serviceProductLine.SubTotal);
                    cmdUpdateProductLine.Parameters.AddWithValue("productLineId", serviceProductLine.ProductLineId);
                    rowsAffected = cmdUpdateProductLine.ExecuteNonQuery();
                }
            }
            return(rowsAffected);
        }
Пример #5
0
        public void InsertOrderTest()
        {
            //Arrange
            DataProduct       dataProduct       = new DataProduct();
            DataCustomerOrder dataCustomerOrder = new DataCustomerOrder();

            ServiceCustomer customer = new ServiceCustomer();

            customer.Name    = "Peter J.";
            customer.Address = "Sofiendalsvej";
            customer.ZipCode = 9000;
            customer.PhoneNo = "12345678";

            ServiceProduct product = new ServiceProduct();

            product = dataProduct.GetProductById(4);

            ServiceProductLine productLine = new ServiceProductLine();

            productLine.Amount   = 1;
            productLine.SubTotal = product.Price;
            productLine.Product  = product;

            ServiceCustomerOrder order = new ServiceCustomerOrder();

            order.FinalPrice    = productLine.SubTotal;
            order.Status        = "Active";
            order.DateOrder     = DateTime.Now;
            order.PaymentMethod = 1;
            order.DiscountCode  = null;
            List <ServiceProductLine> productLines = new List <ServiceProductLine>();

            productLines.Add(productLine);
            order.ShoppingCart = productLines;

            //Act
            bool success = dataCustomerOrder.FinishCheckout(order);


            //Assert
            Assert.IsTrue(success);
        }
Пример #6
0
 public void UpdateProductLine(ServiceProductLine serviceProductLine)
 {
     productLineControl.UpdateProductProductLine(serviceProductLine);
 }
Пример #7
0
 public void InsertProductLine(ServiceProductLine serviceProductLine)
 {
     productLineControl.InsertProductLine(serviceProductLine);
 }
Пример #8
0
 public void InsertProductLine(ServiceProductLine serviceProductLine)
 {
     dataProductLine.InsertProductLine(serviceProductLine);
 }
Пример #9
0
 public void UpdateProductProductLine(ServiceProductLine serviceProductLine)
 {
     dataProductLine.UpdateProductLine(serviceProductLine);
 }