public IActionResult Load(long?ID, long?langId, long?productID)
        {
            GetProductsDetails operation = new GetProductsDetails();

            operation.ID        = ID;
            operation.ProductID = productID;

            if (langId.HasValue)
            {
                operation.LangID = langId;
            }
            else
            {
                operation.LangID = 1;
            }

            var result = operation.QueryAsync().Result;

            if (result is ValidationsOutput)
            {
                return(Ok(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                }));
            }
            else
            {
                return(Ok((List <ProductDetails>)result));
            }
        }
        public IActionResult LoadQuestionnaire(long?langId, long?productID, long?productDetailedID)
        {
            GetProductsDetails operation    = new GetProductsDetails();
            GetQuestionnaire   questionears = new GetQuestionnaire();

            operation.ProductID = productID;

            if (langId.HasValue)
            {
                operation.LangID    = langId;
                questionears.LangID = langId;
            }
            else
            {
                operation.LangID    = 1;
                questionears.LangID = 1;
            }


            var result = operation.QueryAsync().Result;
            var qus    = questionears.QueryAsync().Result;

            var ProductDetails = (List <ProductDetails>)result;

            var productQuestionnaires = (List <Questionnaire>)qus;
            List <Questionnaire> RelatedQuestionnaires   = new List <Questionnaire>();
            List <Questionnaire> UnRelatedQuestionnaires = new List <Questionnaire>();

            if (productQuestionnaires.Count > 0)
            {
                foreach (var prod in ProductDetails)
                {
                    foreach (var item in productQuestionnaires)
                    {
                        if (prod.LineOfBusniess == item.LineOfBusiness && item.SubLineOfBusiness == null)
                        {
                            bool alreadyExist             = UnRelatedQuestionnaires.Contains(item);
                            bool alreadyExistInSecondList = RelatedQuestionnaires.Contains(item);
                            if (!alreadyExist && !alreadyExistInSecondList)
                            {
                                UnRelatedQuestionnaires.Add(item);
                            }
                            else
                            {
                                UnRelatedQuestionnaires.Add(item);

                                RelatedQuestionnaires.Remove(item);
                            }
                        }
                        else
                        {
                            bool alreadyExist            = RelatedQuestionnaires.Contains(item);
                            bool alreadyExistInFirstList = UnRelatedQuestionnaires.Contains(item);
                            if (!alreadyExist && !alreadyExistInFirstList)
                            {
                                RelatedQuestionnaires.Add(item);
                            }
                        }
                    }
                }
            }
            else
            {
                UnRelatedQuestionnaires = productQuestionnaires;
            }
            if (result is ValidationsOutput)
            {
                return(Ok(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                }));
            }
            else
            {
                return(Ok(new { RelatedQuestionnaires, UnRelatedQuestionnaires }));
            }
        }
        public IActionResult LoadRelatedProduct(long?langId, long?productID)
        {
            GetProductsDetails operation   = new GetProductsDetails();
            GetSubBusniess     subBusniess = new GetSubBusniess();

            operation.ProductID = productID;

            if (langId.HasValue)
            {
                operation.LangID   = langId;
                subBusniess.LangID = langId;
            }
            else
            {
                operation.LangID   = 1;
                subBusniess.LangID = 1;
            }


            var result            = operation.QueryAsync().Result;
            var sub               = subBusniess.QueryAsync().Result;
            var ProductDetails    = (List <ProductDetails>)result;
            var SubLineOfBusiness = (List <SubLineOfBusnies>)sub;
            List <SubLineOfBusnies> RelatedSubLine = new List <SubLineOfBusnies>();
            List <SubLineOfBusnies> UnSubLine      = new List <SubLineOfBusnies>();

            if (ProductDetails.Count > 0)
            {
                foreach (var prod in ProductDetails)
                {
                    foreach (var item in SubLineOfBusiness)
                    {
                        if (prod.SubLineOfBusniess == item.ID)
                        {
                            bool alreadyExist             = RelatedSubLine.Contains(item);
                            bool alreadyExistInSecondList = UnSubLine.Contains(item);
                            if (!alreadyExist && !alreadyExistInSecondList)
                            {
                                RelatedSubLine.Add(item);
                            }
                            else
                            {
                                RelatedSubLine.Add(item);
                                UnSubLine.Remove(item);
                            }
                        }
                        else
                        {
                            bool alreadyExist            = RelatedSubLine.Contains(item);
                            bool alreadyExistInFirstList = UnSubLine.Contains(item);
                            if (!alreadyExist && !alreadyExistInFirstList)
                            {
                                UnSubLine.Add(item);
                            }
                        }
                    }
                }
            }
            else
            {
                UnSubLine = SubLineOfBusiness;
            }
            if (result is ValidationsOutput)
            {
                return(Ok(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                }));
            }
            else
            {
                return(Ok(new { RelatedSubLines = RelatedSubLine, UnRelatedSubLines = UnSubLine }));
            }
        }