/// <summary> /// Allocates the product. /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="projProd">The proj product.</param> /// <returns> /// boolean, if allocation to ProjectProduct and Fulfillment table was successful /// </returns> /// Erstellt von Joshua Frey, am 12.01.2016 /// <exception cref="NWATException"></exception> private bool AllocateProduct(int projectId, ProjectProduct projProd) { bool insertionProjectProductSuccessful = true; bool insertionFulfillmentSuccessful = true; int productId = projProd.Product_Id; if (productId != 0 && projProd.Project_Id != 0) { insertionProjectProductSuccessful = InsertProjectProductIntoDb(projProd); // get all project criterions to create new fulfillment entries List <ProjectCriterion> allProjectCriterions; using (ProjectCriterionController projCritCont = new ProjectCriterionController()) { allProjectCriterions = projCritCont.GetAllProjectCriterionsForOneProject(projectId); } // create fulfillment entry for this product and each project criterion using (FulfillmentController fulfillCont = new FulfillmentController()) { foreach (ProjectCriterion projCrit in allProjectCriterions) { int criterionId = projCrit.Criterion_Id; // new fulfillment which will be inserted into fulfillment table. // default values for Fulfilled and Comment (false and null) Fulfillment newFulfillment = new Fulfillment() { Project_Id = projectId, Product_Id = productId, Criterion_Id = criterionId, Fulfilled = false, Comment = null }; if (!fulfillCont.InsertFullfillmentInDb(newFulfillment)) { insertionFulfillmentSuccessful = false; throw (new NWATException(CommonMethods.MessageInsertionToFulFillmentTableFailed(productId, criterionId))); } } } } return(insertionFulfillmentSuccessful && insertionProjectProductSuccessful); }
/// <summary> /// Allocates the criterion. /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="projCrit">The proj crit.</param> /// <returns> /// bool if insertions in projectCriterion table and fulfillment table were successful /// </returns> /// Erstellt von Joshua Frey, am 04.01.2016 /// <exception cref="NWATException"></exception> private bool AllocateCriterion(int projectId, ProjectCriterion projCrit) { bool insertionProjectCritionSuccessful = true; bool insertionFulfillmentSuccessful = true; int projCritId = projCrit.Criterion_Id; if (projCritId != 0 && projCrit.Project_Id != 0) { insertionProjectCritionSuccessful = InsertProjectCriterionIntoDb(projCrit); // get all project products for insertion to fulfillment table List<ProjectProduct> allProjectProducts; using (ProjectProductController projProdCont = new ProjectProductController()) { allProjectProducts = projProdCont.GetAllProjectProductsForOneProject(projectId); } // insert criterions into fulfillment table for each product using (FulfillmentController fulfillContr = new FulfillmentController()) { foreach (ProjectProduct projProd in allProjectProducts) { int productId = projProd.Product_Id; // new fulfillment which will be inserted into fulfillment table. // default values for Fulfilled and Comment (false and null) Fulfillment newFulfillment = new Fulfillment() { Project_Id = projectId, Product_Id = productId, Criterion_Id = projCritId, Fulfilled = false, Comment = null }; if (!fulfillContr.InsertFullfillmentInDb(newFulfillment)) { insertionFulfillmentSuccessful = false; throw (new NWATException(CommonMethods.MessageInsertionToFulFillmentTableFailed(productId, projCritId))); } } } } return insertionFulfillmentSuccessful && insertionProjectCritionSuccessful; }