Esempio n. 1
0
        /// <summary>
        /// Deletes data in the data base using the criteria specified in the CartCriteria object.
        /// </summary>
        /// <param name="criteria">Object of type <see cref="CartCriteria"/></param>
        /// <returns></returns>
        protected void DataPortal_Delete(CartCriteria criteria, SqlConnection connection)
        {
            bool cancel = false;

            OnDeleting(criteria, connection, ref cancel);
            if (cancel)
            {
                return;
            }

            var commandText = String.Format("DELETE FROM [dbo].[Cart] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));

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

                //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.");
                }
            }

            OnDeleted();
        }
Esempio n. 2
0
        /// <summary>
        /// Retrieves data from the data base into a CSLA editable child business object of type <see cref="Cart"/>
        /// using the criteria provided.
        /// </summary>
        /// <param name="criteria">Object of type <see cref="CartCriteria"/></param>
        /// <returns></returns>
        private void Child_Fetch(CartCriteria criteria)
        {
            bool cancel = false;

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

            string commandText = String.Format("SELECT [CartId], [UniqueID], [ItemId], [Name], [Type], [Price], [CategoryId], [ProductId], [IsShoppingCart], [Quantity] FROM [dbo].[Cart] {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.Cart' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            OnChildFetched();
        }
Esempio n. 3
0
        /// <summary>
        /// Returns a <see cref="CartList"/> object of the specified criteria.
        /// </summary>
        /// <param name="isShoppingCart">No additional detail available.</param>
        /// <returns>A <see cref="CartList"/> object of the specified criteria.</returns>
        internal static CartList GetByIsShoppingCart(System.Boolean isShoppingCart)
        {
            var criteria = new CartCriteria {
                IsShoppingCart = isShoppingCart
            };


            return(DataPortal.FetchChild <CartList>(criteria));
        }
Esempio n. 4
0
        /// <summary>
        /// Returns a <see cref="CartList"/> object of the specified criteria.
        /// </summary>
        /// <param name="uniqueID">No additional detail available.</param>
        /// <returns>A <see cref="CartList"/> object of the specified criteria.</returns>
        internal static CartList GetByUniqueID(System.Int32 uniqueID)
        {
            var criteria = new CartCriteria {
                UniqueID = uniqueID
            };


            return(DataPortal.FetchChild <CartList>(criteria));
        }
Esempio n. 5
0
        /// <summary>
        /// Returns a <see cref="CartList"/> object of the specified criteria.
        /// </summary>
        /// <param name="cartId">No additional detail available.</param>
        /// <returns>A <see cref="CartList"/> object of the specified criteria.</returns>
        internal static CartList GetByCartId(System.Int32 cartId)
        {
            var criteria = new CartCriteria {
                CartId = cartId
            };


            return(DataPortal.FetchChild <CartList>(criteria));
        }
Esempio n. 6
0
        internal static async Task <CartList> GetByIsShoppingCartAsync(System.Boolean isShoppingCart)
        {
            var criteria = new CartCriteria {
                IsShoppingCart = isShoppingCart
            };


            return(await DataPortal.FetchAsync <AsyncChildLoader <CartList> >(criteria).ContinueWith(t => t.Result.Child));
        }
Esempio n. 7
0
        internal static async Task <CartList> GetByUniqueIDAsync(System.Int32 uniqueID)
        {
            var criteria = new CartCriteria {
                UniqueID = uniqueID
            };


            return(await DataPortal.FetchAsync <AsyncChildLoader <CartList> >(criteria).ContinueWith(t => t.Result.Child));
        }
Esempio n. 8
0
        internal static async Task <CartList> GetByCartIdAsync(System.Int32 cartId)
        {
            var criteria = new CartCriteria {
                CartId = cartId
            };


            return(await DataPortal.FetchAsync <AsyncChildLoader <CartList> >(criteria).ContinueWith(t => t.Result.Child));
        }
        private void Child_Fetch(CartCriteria criteria)
        {
            bool cancel = false;

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

            RaiseListChangedEvents = false;

            // Fetch Child objects.
            string commandText = String.Format("SELECT [CartId], [UniqueID], [ItemId], [Name], [Type], [Price], [CategoryId], [ProductId], [IsShoppingCart], [Quantity] FROM [dbo].[Cart] {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.Cart.GetCart(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            RaiseListChangedEvents = true;

            OnFetched();
        }
Esempio n. 10
0
 internal static CartList GetByCriteria(CartCriteria criteria)
 {
     return(DataPortal.Fetch <CartList>(criteria));
 }
Esempio n. 11
0
 /// <summary>
 /// Determines if a record exists in the Cart in the database for the specified criteria.
 /// </summary>
 public static async Task <bool> ExistsAsync(CartCriteria criteria)
 {
     return(await PetShop.Business.ExistsCommand.ExecuteAsync(criteria));
 }
Esempio n. 12
0
 /// <summary>
 /// Determines if a record exists in the Cart in the database for the specified criteria.
 /// </summary>
 /// <param name="criteria">The criteria parameter is a <see cref="CartList"/> object.</param>
 /// <returns>A boolean value of true is returned if a record is found.</returns>
 public static bool Exists(CartCriteria criteria)
 {
     return(PetShop.Business.Cart.Exists(criteria));
 }
Esempio n. 13
0
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="Cart"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="CartCriteria"/> object containing the criteria of the object to delete.</param>
 /// <param name="connection"></param>
 /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param>
 partial void OnDeleting(CartCriteria criteria, SqlConnection connection, ref bool cancel);
Esempio n. 14
0
 internal static async Task <CartList> GetByCriteriaAsync(CartCriteria criteria)
 {
     return(await DataPortal.FetchAsync <AsyncChildLoader <CartList> >(criteria).ContinueWith(t => t.Result.Child));
 }
Esempio n. 15
0
 /// <summary>
 /// Determines if a record exists in the Cart table in the database for the specified criteria.
 /// </summary>
 /// <param name="criteria">The criteria parameter is an <see cref="Cart"/> object.</param>
 /// <returns>A boolean value of true is returned if a record is found.</returns>
 public static bool Exists(CartCriteria criteria)
 {
     return(PetShop.Business.ExistsCommand.Execute(criteria));
 }
Esempio n. 16
0
 /// <summary>
 /// CodeSmith generated stub method that is called when fetching the child <see cref="Cart"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="CartCriteria"/> 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(CartCriteria criteria, ref bool cancel);
Esempio n. 17
0
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="Cart"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="CartCriteria"/> 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(CartCriteria criteria, ref bool cancel);