/// <summary>
        /// Inserts the criterion into database.
        /// </summary>
        /// <param name="newCriterion">The new criterion.</param>
        /// <returns>
        /// bool if insert of new criterion was successfull.
        /// </returns>
        /// Erstellt von Joshua Frey, am 14.12.2015
        /// <exception cref="NWATException">
        /// </exception>
        public bool InsertCriterionIntoDb(Criterion newCriterion)
        {
            if (newCriterion != null)
            {
                // if insert Id is != 0 then this criterion will be imported at the index of insertId
                bool willBeImported = newCriterion.Criterion_Id != 0;

                string newCriterionName = newCriterion.Name;
                if (!CheckIfCriterionNameAlreadyExists(newCriterionName))
                {

                    if (willBeImported)
                    {
                        if (CheckIfCriterionIdAlreadyExists(newCriterion.Criterion_Id))
                        {
                            throw (new NWATException(MessageCriterionIdAlreadyExists(newCriterion.Criterion_Id)));
                        }
                        else
                        {
                            base.DataContext.Criterion.InsertOnSubmit(newCriterion);
                            base.DataContext.SubmitChanges();
                        }
                    }
                    else
                    {
                        using (CurrentMasterDataIdsController masterDataIdsContr = new CurrentMasterDataIdsController())
                        {
                            CurrentMasterDataIds masterDataIdsSet = masterDataIdsContr.GetCurrentMasterDataIds();

                            int currentCritId = masterDataIdsSet.CurrentCriterionId;

                            // if you inserted a criterion manually and forgot to adjust the currentCriterionId it will
                            // increment to the free place and will use new id to insert new criterion
                            while (GetCriterionById(currentCritId) != null)
                            {
                                masterDataIdsContr.incrementCurrentCriterionId();
                                currentCritId = masterDataIdsSet.CurrentCriterionId;
                            }

                            newCriterion.Criterion_Id = currentCritId;

                            base.DataContext.Criterion.InsertOnSubmit(newCriterion);
                            base.DataContext.SubmitChanges();
                            masterDataIdsContr.incrementCurrentCriterionId();
                        }
                    }
                }
                else
                {
                    throw (new NWATException((MessageCriterionAlreadyExists(newCriterionName))));
                }
            }
            else
            {
                throw (new NWATException(MessageCriterionCouldNotBeSavedEmptyObject()));
            }

            Criterion newCriterionFromDb = (from crit in base.DataContext.Criterion
                                            where crit.Name == newCriterion.Name
                                            && crit.Description == newCriterion.Description
                                            select crit).FirstOrDefault();
            return CheckIfEqualCriterions(newCriterion, newCriterionFromDb);
        }
        /// <summary>
        /// Inserts the product into database.
        /// </summary>
        /// <param name="newProduct">The new product.</param>
        /// <returns>
        /// bool if insert of new product was successfull.
        /// </returns>
        /// Erstellt von Joshua Frey, am 14.12.2015
        /// <exception cref="NWATException">
        /// </exception>
        public bool InsertProductIntoDb(Product newProduct)
        {
            if (newProduct != null)
            {
                // if insert Id is != 0 then this project will be imported at the index of insertId
                bool willBeImported = newProduct.Product_Id != 0;

                string newProductName = newProduct.Name;
                if (!CheckIfProductNameAlreadyExists(newProductName))
                {
                    if (willBeImported)
                    {
                        if (CheckIfProductIdAlreadyExists(newProduct.Product_Id))
                        {
                            throw (new NWATException(MessageProductIdAlreadyExists(newProduct.Product_Id)));
                        }
                        else
                        {
                            base.DataContext.Product.InsertOnSubmit(newProduct);
                            base.DataContext.SubmitChanges();
                        }
                    }
                    else
                    {
                        using (CurrentMasterDataIdsController masterDataIdsContr = new CurrentMasterDataIdsController())
                        {
                            CurrentMasterDataIds masterDataIdsSet = masterDataIdsContr.GetCurrentMasterDataIds();

                            int currentProdId = masterDataIdsSet.CurrentProductId;

                            // if you inserted a product manually and forgot to adjust the currentProductId it will
                            // increment to the free place and will use new id to insert new product
                            while (GetProductById(currentProdId) != null)
                            {
                                masterDataIdsContr.incrementCurrentProductId();
                                currentProdId = masterDataIdsSet.CurrentProductId;
                            }

                            newProduct.Product_Id = currentProdId;
                            base.DataContext.Product.InsertOnSubmit(newProduct);
                            base.DataContext.SubmitChanges();
                            masterDataIdsContr.incrementCurrentProductId();
                        }
                    }
                }
                else
                {
                    throw (new NWATException((MessageProductAlreadyExists(newProductName))));
                }
            }
            else
            {
                throw (new NWATException(MessageProductCouldNotBeSavedEmptyObject()));
            }

            Product newProductFromDb = (from prod in base.DataContext.Product
                                        where prod.Name == newProduct.Name &&
                                        prod.Producer == newProduct.Producer &&
                                        prod.Price == newProduct.Price
                                        select prod).FirstOrDefault();

            return(CheckIfEqualProducts(newProduct, newProductFromDb));
        }
        /// <summary>
        /// Inserts the criterion into database.
        /// </summary>
        /// <param name="newCriterion">The new criterion.</param>
        /// <returns>
        /// bool if insert of new criterion was successfull.
        /// </returns>
        /// Erstellt von Joshua Frey, am 14.12.2015
        /// <exception cref="NWATException">
        /// </exception>
        public bool InsertCriterionIntoDb(Criterion newCriterion)
        {
            if (newCriterion != null)
            {
                // if insert Id is != 0 then this criterion will be imported at the index of insertId
                bool willBeImported = newCriterion.Criterion_Id != 0;

                string newCriterionName = newCriterion.Name;
                if (!CheckIfCriterionNameAlreadyExists(newCriterionName))
                {
                    if (willBeImported)
                    {
                        if (CheckIfCriterionIdAlreadyExists(newCriterion.Criterion_Id))
                        {
                            throw (new NWATException(MessageCriterionIdAlreadyExists(newCriterion.Criterion_Id)));
                        }
                        else
                        {
                            base.DataContext.Criterion.InsertOnSubmit(newCriterion);
                            base.DataContext.SubmitChanges();
                        }
                    }
                    else
                    {
                        using (CurrentMasterDataIdsController masterDataIdsContr = new CurrentMasterDataIdsController())
                        {
                            CurrentMasterDataIds masterDataIdsSet = masterDataIdsContr.GetCurrentMasterDataIds();

                            int currentCritId = masterDataIdsSet.CurrentCriterionId;

                            // if you inserted a criterion manually and forgot to adjust the currentCriterionId it will
                            // increment to the free place and will use new id to insert new criterion
                            while (GetCriterionById(currentCritId) != null)
                            {
                                masterDataIdsContr.incrementCurrentCriterionId();
                                currentCritId = masterDataIdsSet.CurrentCriterionId;
                            }

                            newCriterion.Criterion_Id = currentCritId;

                            base.DataContext.Criterion.InsertOnSubmit(newCriterion);
                            base.DataContext.SubmitChanges();
                            masterDataIdsContr.incrementCurrentCriterionId();
                        }
                    }
                }
                else
                {
                    throw (new NWATException((MessageCriterionAlreadyExists(newCriterionName))));
                }
            }
            else
            {
                throw (new NWATException(MessageCriterionCouldNotBeSavedEmptyObject()));
            }

            Criterion newCriterionFromDb = (from crit in base.DataContext.Criterion
                                            where crit.Name == newCriterion.Name &&
                                            crit.Description == newCriterion.Description
                                            select crit).FirstOrDefault();

            return(CheckIfEqualCriterions(newCriterion, newCriterionFromDb));
        }