コード例 #1
0
        public RiskFactorTypeDetail Add()
        {
            // there is no hierarchy so parent can be safely ignored
            RiskFactorTypeDetail detail = new RiskFactorTypeDetail();
            detail.Default(Context.UserName);

            RiskFactorType main = new RiskFactorType();
            main.Default(Context.UserName);

            if (Context.RiskFactorTypes.Local.Count() > 0)
                main.RiskFactorTypeID = Context.RiskFactorTypes.Local.Max(x => x.RiskFactorTypeID) + 1;
            else
                main.RiskFactorTypeID = 1;

            detail.RiskFactorType = main;
            detail.RiskFactorTypeID = main.RiskFactorTypeID;
            detail.Name = "Risk Factor Type Name";
            Context.RiskFactorTypes.Add(main);
            Context.RiskFactorTypeDetails.Add(detail);

            return detail;
        }
コード例 #2
0
        public void TestSaveRiskFactorType()
        {
            string name = "Risk Factor Test Name";
            RiskFactorType main;
            RiskFactorTypeDetail detail;
            RiskFactorTypeGroup group;

            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                group = context.RiskFactorTypeGroups.Find(2);

                main = new RiskFactorType();
                main.Default(UserName);
                context.RiskFactorTypes.Add(main);
                detail = new RiskFactorTypeDetail();
                detail.Default(UserName);
                main.RiskFactorTypeDetails.Add(detail);
                detail.Name = name;
                detail.RiskFactorTypeGroupID = group.RiskFactorTypeGroupID;

                context.SaveChanges();
            }

            using (var context = new ScenarioGeneratorModel(UserName, Connection))
            {
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                detail = context.RiskFactorTypeDetails.Where(a => a.Name == name).FirstOrDefault();
                Assert.AreEqual(name, detail.Name);
                Assert.AreEqual(true, detail.Latest);
                Assert.AreEqual(DateTime.MinValue, detail.StartTime);
                Assert.AreEqual(DateTime.MaxValue, detail.EndTime);
                Assert.AreEqual(EntityStatus.Unapproved, detail.Status);

                main = detail.RiskFactorType;
                Assert.AreEqual(true, main.Latest);
                Assert.AreEqual(DateTime.MinValue, main.StartTime);
                Assert.AreEqual(DateTime.MaxValue, main.EndTime);
                Assert.AreEqual(DateTime.MaxValue, main.EndTime);
                Assert.AreEqual(EntityStatus.Unapproved, main.Status);

            }
        }
コード例 #3
0
        //returns false, if a move is not possible
        public bool Move(RiskFactorTypeDetail detail, RiskFactorTypeGroup group)
        {
            RiskFactorTypeGroup checkParent = group;

            detail.RiskFactorTypeGroup = group;
            detail.RiskFactorTypeGroupID = group.RiskFactorTypeGroupID;

            //reset the values - we have new version, which is unapproved
            //it will be finalised during save
            if (detail.Status == EntityStatus.Approved)
                detail.Default(Context.UserName);

            return true;
        }