Ejemplo n.º 1
0
        /*
         * Private section
         */


        /// <summary>
        /// Deallocates the product from project and deletes all allocated fulfillment entries
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="productToDeallocate">The product to deallocate.</param>
        /// <returns>
        /// boolean, if deallocation was successful and all allocated fulfillment entries were delted successfully
        /// </returns>
        /// Erstellt von Joshua Frey, am 12.01.2016
        private bool DeallocateProductFromProject(int projectId, ProjectProduct productToDeallocate)
        {
            bool   fulfillmentDeletionSuccessful;
            int    idOfProductToDeallocate   = productToDeallocate.Product_Id;
            string nameOfProductToDeallocate = productToDeallocate.Product.Name;

            using (FulfillmentController fulfillContr = new FulfillmentController())
            {
                fulfillmentDeletionSuccessful = fulfillContr.DeleteAllFulfillmentsForOneProductInOneProject(projectId, idOfProductToDeallocate);
            }

            if (fulfillmentDeletionSuccessful && DeleteProjectProductFromDb(projectId, idOfProductToDeallocate))
            {
                return(true);
            }
            else
            {
                MessageBox.Show(String.Format(@"Bei dem Entkoppeln des Produkts {0} ist ein Fehler aufgetreten."), nameOfProductToDeallocate);
                return(false);
            }
        }
        /*
         * Private section
         */
        /// <summary>
        /// Deallocates the product from project and deletes all allocated fulfillment entries
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="productToDeallocate">The product to deallocate.</param>
        /// <returns>
        /// boolean, if deallocation was successful and all allocated fulfillment entries were delted successfully
        /// </returns>
        /// Erstellt von Joshua Frey, am 12.01.2016
        private bool DeallocateProductFromProject(int projectId, ProjectProduct productToDeallocate)
        {
            bool fulfillmentDeletionSuccessful;
            int idOfProductToDeallocate = productToDeallocate.Product_Id;
            string nameOfProductToDeallocate = productToDeallocate.Product.Name;
            using (FulfillmentController fulfillContr = new FulfillmentController())
            {
                fulfillmentDeletionSuccessful = fulfillContr.DeleteAllFulfillmentsForOneProductInOneProject(projectId, idOfProductToDeallocate);
            }

            if (fulfillmentDeletionSuccessful && DeleteProjectProductFromDb(projectId, idOfProductToDeallocate))
            {
                return true;
            }
            else
            {
                MessageBox.Show(String.Format(@"Bei dem Entkoppeln des Produkts {0} ist ein Fehler aufgetreten."), nameOfProductToDeallocate);
                return false;
            }
        }