Example #1
0
        internal static async Task <Product> GetByCategoryIdChildAsync(System.String categoryId)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId
            };


            return(await DataPortal.FetchAsync <Product>(criteria));
        }
Example #2
0
        internal static async Task <Product> GetByNameChildAsync(System.String name)
        {
            var criteria = new ProductCriteria {
                Name = name
            };


            return(await DataPortal.FetchAsync <Product>(criteria));
        }
Example #3
0
        public static async Task DeleteProductAsync(System.String productId)
        {
            var criteria = new ProductCriteria {
                ProductId = productId
            };


            await DataPortal.DeleteAsync <Product>(criteria);
        }
Example #4
0
        /// <summary>
        /// Returns a <see cref="Product"/> object of the specified criteria.
        /// </summary>
        /// <param name="name">No additional detail available.</param>
        /// <returns>A <see cref="Product"/> object of the specified criteria.</returns>
        internal static Product GetByNameChild(System.String name)
        {
            var criteria = new ProductCriteria {
                Name = name
            };


            return(DataPortal.FetchChild <Product>(criteria));
        }
Example #5
0
        public static async Task <Product> GetByProductIdAsync(System.String productId)
        {
            var criteria = new ProductCriteria {
                ProductId = productId
            };


            return(await DataPortal.FetchAsync <Product>(criteria));
        }
Example #6
0
        /// <summary>
        /// Returns a <see cref="Product"/> object of the specified criteria.
        /// </summary>
        /// <param name="categoryId">No additional detail available.</param>
        /// <param name="name">No additional detail available.</param>
        /// <returns>A <see cref="Product"/> object of the specified criteria.</returns>
        public static Product GetByCategoryIdName(System.String categoryId, System.String name)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId, Name = name
            };


            return(DataPortal.Fetch <Product>(criteria));
        }
Example #7
0
        /// <summary>
        /// Returns a <see cref="Product"/> object of the specified criteria.
        /// </summary>
        /// <param name="name">No additional detail available.</param>
        /// <returns>A <see cref="Product"/> object of the specified criteria.</returns>
        public static Product GetByName(System.String name)
        {
            var criteria = new ProductCriteria {
                Name = name
            };


            return(DataPortal.Fetch <Product>(criteria));
        }
Example #8
0
        internal static async Task <Product> GetByCategoryIdProductIdNameChildAsync(System.String categoryId, System.String productId, System.String name)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId, ProductId = productId, Name = name
            };


            return(await DataPortal.FetchAsync <Product>(criteria));
        }
        /// <summary>
        /// Returns a <see cref="ProductList"/> object of the specified criteria.
        /// </summary>
        /// <param name="categoryId">No additional detail available.</param>
        /// <param name="productId">No additional detail available.</param>
        /// <param name="name">No additional detail available.</param>
        /// <returns>A <see cref="ProductList"/> object of the specified criteria.</returns>
        internal static ProductList GetByCategoryIdProductIdName(System.String categoryId, System.String productId, System.String name)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId, ProductId = productId, Name = name
            };


            return(DataPortal.FetchChild <ProductList>(criteria));
        }
Example #10
0
        /// <summary>
        /// Returns a <see cref="Product"/> object of the specified criteria.
        /// </summary>
        /// <param name="productId">No additional detail available.</param>
        /// <returns>A <see cref="Product"/> object of the specified criteria.</returns>
        public static Product GetByProductId(System.String productId)
        {
            var criteria = new ProductCriteria {
                ProductId = productId
            };


            return(DataPortal.Fetch <Product>(criteria));
        }
        /// <summary>
        /// Returns a <see cref="ProductList"/> object of the specified criteria.
        /// </summary>
        /// <param name="categoryId">No additional detail available.</param>
        /// <returns>A <see cref="ProductList"/> object of the specified criteria.</returns>
        internal static ProductList GetByCategoryId(System.String categoryId)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId
            };


            return(DataPortal.FetchChild <ProductList>(criteria));
        }
        internal static async Task <ProductList> GetByCategoryIdProductIdNameAsync(System.String categoryId, System.String productId, System.String name)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId, ProductId = productId, Name = name
            };


            return(await DataPortal.FetchAsync <AsyncChildLoader <ProductList> >(criteria).ContinueWith(t => t.Result.Child));
        }
        /// <summary>
        /// Returns a <see cref="ProductList"/> object of the specified criteria.
        /// </summary>
        /// <param name="productId">No additional detail available.</param>
        /// <returns>A <see cref="ProductList"/> object of the specified criteria.</returns>
        internal static ProductList GetByProductId(System.String productId)
        {
            var criteria = new ProductCriteria {
                ProductId = productId
            };


            return(DataPortal.FetchChild <ProductList>(criteria));
        }
        internal static async Task <ProductList> GetByProductIdAsync(System.String productId)
        {
            var criteria = new ProductCriteria {
                ProductId = productId
            };


            return(await DataPortal.FetchAsync <AsyncChildLoader <ProductList> >(criteria).ContinueWith(t => t.Result.Child));
        }
Example #15
0
        /// <summary>
        /// Returns a <see cref="Product"/> object of the specified criteria.
        /// </summary>
        /// <param name="categoryId">No additional detail available.</param>
        /// <returns>A <see cref="Product"/> object of the specified criteria.</returns>
        public static Product GetByCategoryId(System.String categoryId)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId
            };


            return(DataPortal.Fetch <Product>(criteria));
        }
Example #16
0
        private void Child_Fetch(ProductCriteria criteria)
        {
            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return;
            }

            RaiseListChangedEvents = false;

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Product_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_DescnHasValue", criteria.DescriptionHasValue);
                    command.Parameters.AddWithValue("@p_ImageHasValue", criteria.ImageHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                this.Add(PetShop.Tests.StoredProcedures.Product.GetProduct(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            RaiseListChangedEvents = true;

            OnFetched();
        }
Example #17
0
        private void Child_Fetch(ProductCriteria criteria)
        {
            bool cancel = false;

            OnChildFetching(criteria, ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Product_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_DescnHasValue", criteria.DescriptionHasValue);
                    command.Parameters.AddWithValue("@p_ImageHasValue", criteria.ImageHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            Map(reader);
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.Product' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            OnChildFetched();


            MarkAsChild();
        }
Example #18
0
        protected override void DataPortal_Update()
        {
            bool cancel = false;

            OnUpdating(ref cancel);
            if (cancel)
            {
                return;
            }

            if (OriginalProductId != ProductId)
            {
                // Insert new child.
                Product item = new Product {
                    ProductId = ProductId, CategoryId = CategoryId, Name = Name, Description = Description, Image = Image
                };

                item = item.Save();

                // Mark editable child lists as dirty. This code may need to be updated to one-to-one relationships.
                foreach (Item itemToUpdate in Items)
                {
                    itemToUpdate.ProductId = ProductId;
                }

                // Create a new connection.
                using (var connection = new SqlConnection(ADOHelper.ConnectionString))
                {
                    connection.Open();
                    FieldManager.UpdateChildren(this, connection);
                }

                // Delete the old.
                var criteria = new ProductCriteria {
                    ProductId = OriginalProductId
                };

                DataPortal_Delete(criteria);

                // Mark the original as the new one.
                OriginalProductId = ProductId;
                OnUpdated();

                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Product_Update]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_OriginalProductId", this.OriginalProductId);
                    command.Parameters.AddWithValue("@p_ProductId", this.ProductId);
                    command.Parameters.AddWithValue("@p_CategoryId", this.CategoryId);
                    command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                    command.Parameters.AddWithValue("@p_Descn", ADOHelper.NullCheck(this.Description));
                    command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(this.Image));
                    //result: The number of rows changed, inserted, or deleted. -1 for select statements; 0 if no rows were affected, or the statement failed.
                    int result = command.ExecuteNonQuery();
                    if (result == 0)
                    {
                        throw new DBConcurrencyException("The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute.");
                    }

                    LoadProperty(_originalProductIdProperty, this.ProductId);
                }

                FieldManager.UpdateChildren(this, connection);
            }

            OnUpdated();
        }
 /// <summary>
 /// Determines if a record exists in the Product in the database for the specified criteria.
 /// </summary>
 public static async Task <bool> ExistsAsync(ProductCriteria criteria)
 {
     return(await PetShop.Tests.StoredProcedures.ExistsCommand.ExecuteAsync(criteria));
 }
 /// <summary>
 /// Determines if a record exists in the Product in the database for the specified criteria.
 /// </summary>
 /// <param name="criteria">The criteria parameter is a <see cref="ProductList"/> object.</param>
 /// <returns>A boolean value of true is returned if a record is found.</returns>
 public static bool Exists(ProductCriteria criteria)
 {
     return(PetShop.Tests.StoredProcedures.Product.Exists(criteria));
 }
 /// <summary>
 /// CodeSmith generated stub method that is called when fetching the child <see cref="Product"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="ProductCriteria"/> object containing the criteria of the object to fetch.</param>
 /// <param name="cancel">Value returned from the method indicating whether the object fetching should proceed.</param>
 partial void OnFetching(ProductCriteria criteria, ref bool cancel);
 internal static async Task <ProductList> GetByCriteriaAsync(ProductCriteria criteria)
 {
     return(await DataPortal.FetchAsync <AsyncChildLoader <ProductList> >(criteria).ContinueWith(t => t.Result.Child));
 }
 internal static ProductList GetByCriteria(ProductCriteria criteria)
 {
     return(DataPortal.Fetch <ProductList>(criteria));
 }
Example #24
0
 /// <summary>
 /// Determines if a record exists in the Product table in the database for the specified criteria.
 /// </summary>
 /// <param name="criteria">The criteria parameter is an <see cref="Product"/> object.</param>
 /// <returns>A boolean value of true is returned if a record is found.</returns>
 public static bool Exists(ProductCriteria criteria)
 {
     return(PetShop.Tests.StoredProcedures.ExistsCommand.Execute(criteria));
 }
Example #25
0
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the <see cref="Product"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="ProductCriteria"/> object containing the criteria of the object to delete.</param>
 /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param>
 partial void OnDeleting(ProductCriteria criteria, ref bool cancel);