Exemple #1
0
        /// <summary>
        /// Returns a <see cref="Product"/> 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="Product"/> object of the specified criteria.</returns>
        internal static Product GetByCategoryIdProductIdNameChild(System.String categoryId, System.String productId, System.String name)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId, ProductId = productId, Name = name
            };


            return(DataPortal.FetchChild <Product>(criteria));
        }
Exemple #2
0
        internal static async Task <Product> GetByCategoryIdChildAsync(System.String categoryId)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId
            };


            return(await DataPortal.FetchAsync <Product>(criteria));
        }
Exemple #3
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>
        internal static Product GetByCategoryIdChild(System.String categoryId)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId
            };


            return(DataPortal.FetchChild <Product>(criteria));
        }
Exemple #4
0
        public static async Task <ProductList> GetByCategoryIdNameAsync(System.String categoryId, System.String name)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId, Name = name
            };


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


            await DataPortal.DeleteAsync <Product>(criteria);
        }
Exemple #6
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>
        internal static Product GetByProductIdChild(System.String productId)
        {
            var criteria = new ProductCriteria {
                ProductId = productId
            };


            return(DataPortal.FetchChild <Product>(criteria));
        }
Exemple #7
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));
        }
Exemple #8
0
        public static async Task <Product> GetByProductIdAsync(System.String productId)
        {
            var criteria = new ProductCriteria {
                ProductId = productId
            };


            return(await DataPortal.FetchAsync <Product>(criteria));
        }
Exemple #9
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));
        }
Exemple #10
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));
        }
Exemple #11
0
        /// <summary>
        /// Returns a <see cref="ProductList"/> collection of <see cref="Product"/> items with the specified criteria.
        /// </summary>
        /// <param name="categoryId">No additional detail available.</param>
        /// <returns>Collection of all <see cref="Product"/> items.</returns>
        public static ProductList GetByCategoryId(System.String categoryId)
        {
            var criteria = new ProductCriteria {
                CategoryId = categoryId
            };


            return(DataPortal.Fetch <ProductList>(criteria));
        }
Exemple #12
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));
        }
Exemple #13
0
        internal static async Task <Product> GetByNameChildAsync(System.String name)
        {
            var criteria = new ProductCriteria {
                Name = name
            };


            return(await DataPortal.FetchAsync <Product>(criteria));
        }
Exemple #14
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));
        }
        private void DataPortal_Fetch(ProductCriteria criteria)
        {
            bool cancel = false;

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

            RaiseListChangedEvents = false;

            // Fetch Child objects.
            string commandText = String.Format("SELECT [ProductId], [CategoryId], [Name], [Descn], [Image] FROM [dbo].[Product] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                this.Add(PetShop.Business.Product.GetProduct(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            RaiseListChangedEvents = true;

            OnFetched();
        }
        private void Child_Fetch(ProductCriteria criteria)
        {
            bool cancel = false;

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

            string commandText = String.Format("SELECT [ProductId], [CategoryId], [Name], [Descn], [Image] FROM [dbo].[Product] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    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();
        }
Exemple #17
0
 public static ProductList GetByCriteria(ProductCriteria criteria)
 {
     return(DataPortal.Fetch <ProductList>(criteria));
 }
Exemple #18
0
 public static async Task <ProductList> GetByCriteriaAsync(ProductCriteria criteria)
 {
     return(await DataPortal.FetchAsync <ProductList>(criteria));
 }
        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;
            }

            const string commandText = "UPDATE [dbo].[Product] SET [ProductId] = @p_ProductId, [CategoryId] = @p_CategoryId, [Name] = @p_Name, [Descn] = @p_Descn, [Image] = @p_Image WHERE [ProductId] = @p_OriginalProductId; SELECT [ProductId] FROM [dbo].[Product] WHERE [ProductId] = @p_OriginalProductId";

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    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();
        }
Exemple #20
0
 /// <summary>
 /// Determines if a record exists in the Product table in the database for the specified criteria.
 /// </summary>
 public static async Task <bool> ExistsAsync(ProductCriteria criteria)
 {
     return(await PetShop.Business.ExistsCommand.ExecuteAsync(criteria));
 }
Exemple #21
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.Business.ExistsCommand.Execute(criteria));
 }
Exemple #22
0
 /// <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 OnChildFetching(ProductCriteria criteria, ref bool cancel);
Exemple #23
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);
Exemple #24
0
 /// <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.Business.Product.Exists(criteria));
 }