Пример #1
0
 public void SetRequirementForSet(REQUIREMENT_SETS set)
 {
     if (!IsRequirement)
     {
         SortSet         = set == null ? Question.Original_Set_NameNavigation : set.Set_NameNavigation;
         NEW_REQUIREMENT = set == null?Question.NEW_REQUIREMENTs().FirstOrDefault() : set.Requirement_;
     }
 }
        private NEW_QUESTION BuildFromNewQuestion(BaseQuestionInfoData infoData, SETS set, CSET_Context controlContext)
        {
            NEW_QUESTION       question          = infoData.Question;
            NEW_REQUIREMENT    requirement       = null;
            RequirementTabData tabData           = new RequirementTabData();
            string             shortStandardName = set.Short_Name;

            HeaderName = shortStandardName;
            Question_or_Requirement_Id = infoData.QuestionID;

            this.LevelName = (from a in controlContext.NEW_QUESTION_SETS.Where(t => t.Question_Id == infoData.QuestionID && t.Set_Name == infoData.Set.Set_Name)
                              join l in controlContext.NEW_QUESTION_LEVELS on a.New_Question_Set_Id equals l.New_Question_Set_Id
                              join u in controlContext.UNIVERSAL_SAL_LEVEL on l.Universal_Sal_Level equals u.Universal_Sal_Level1
                              orderby u.Sal_Level_Order
                              select u.Full_Name_Sal).FirstOrDefault();

            // Gets requirements for the current standard (Set)
            IEnumerable <NEW_REQUIREMENT> requires = null;

            if (set.Is_Custom)
            {
                //Legacy only
                var tempRequires = new List <NEW_REQUIREMENT>();
                foreach (var setName in set.CUSTOM_STANDARD_BASE_STANDARDBase_StandardNavigation.Select(s => s.Base_Standard).ToList())
                {
                    tempRequires = tempRequires.Concat(question.NEW_REQUIREMENTs().Where(t => t.REQUIREMENT_SETS.Select(s => s.Set_Name).Contains(setName)).ToList()).ToList();
                }
                requires = tempRequires;
            }
            if (requires == null || !requires.Any())
            {
                requires = from a in controlContext.NEW_REQUIREMENT
                           join b in controlContext.REQUIREMENT_QUESTIONS_SETS on a.Requirement_Id equals b.Requirement_Id
                           where b.Question_Id == infoData.QuestionID && b.Set_Name == set.Set_Name
                           select a;
            }

            requirement = requires.FirstOrDefault();
            if (requirement != null)
            {
                tabData.Set_Name      = set.Set_Name;
                tabData.Text          = FormatRequirementText(requirement.Requirement_Text);
                tabData.RequirementID = requirement.Requirement_Id;
                if (!IsComponent)
                {
                    RequirementFrameworkTitle = requirement.Requirement_Title;
                }


                RelatedFrameworkCategory = requirement.Standard_Sub_Category;

                if (RelatedFrameworkCategory == null)
                {
                    var query = from qgh in controlContext.QUESTION_GROUP_HEADING
                                join usch in controlContext.UNIVERSAL_SUB_CATEGORY_HEADINGS on qgh.Question_Group_Heading_Id equals usch.Question_Group_Heading_Id
                                join q in controlContext.NEW_QUESTION on usch.Heading_Pair_Id equals q.Heading_Pair_Id
                                where q.Question_Id == question.Question_Id
                                select qgh.Question_Group_Heading1;
                    RelatedFrameworkCategory = query.FirstOrDefault();
                }

                tabData.SupplementalInfo = requires.FirstOrDefault(s => !String.IsNullOrEmpty(s.Supplemental_Info))?.Supplemental_Info;
                tabData.SupplementalInfo = FormatSupplementalInfo(tabData.SupplementalInfo);

                BuildDocuments(requirement.Requirement_Id, controlContext);
            }
            QuestionsVisible         = false;
            ShowRequirementStandards = false;
            ShowSALLevel             = true;
            RequirementsData         = tabData;
            return(question);
        }