Ejemplo n.º 1
0
        private static void AddScenarioLocuses1(ScenarioGeneratorModel context)
        {
            DateTime now = context.AsOfDate;

            ScenarioDetail scenario = context.ScenarioDetails.Where(x => x.Name == "Scenario IR Rate").First();

            ScenarioLocus locus;
            RiskFactorDimItemDetail dimItem;
            ScenarioLocusDimItem locusDimItem;

            RiskFactorDimension dimension = scenario.RiskFactorType.RiskFactorTypeDimensions.Where(d => d.RiskFactorDimension.RiskFactorDimensionDetail.Name == "Currency").First().RiskFactorDimension;

            locus = new ScenarioLocus() { ScenarioDetailID = scenario.ScenarioDetailID, StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-200), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            locus.RiskFactorDimension = dimension;
            scenario.ScenarioLocuses.Add(locus);

            dimItem = context.RiskFactorDimItemDetails.Where(i => i.Name == "USD" && i.RiskFactorDimItem.RiskFactorDimTypeID == dimension.RiskFactorDimensionDetail.RiskFactorDimTypeID).First();
            locusDimItem = new ScenarioLocusDimItem() { RiskFactorDimItem = dimItem.RiskFactorDimItem, StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-200), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            locus.ScenarioLocusDimItems.Add(locusDimItem);

            dimItem = context.RiskFactorDimItemDetails.Where(i => i.Name == "PLN" && i.RiskFactorDimItem.RiskFactorDimTypeID == dimension.RiskFactorDimensionDetail.RiskFactorDimTypeID).First();
            locusDimItem = new ScenarioLocusDimItem() { RiskFactorDimItem = dimItem.RiskFactorDimItem, StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-200), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            locus.ScenarioLocusDimItems.Add(locusDimItem);

            dimItem = context.RiskFactorDimItemDetails.Where(i => i.Name == "EUR" && i.RiskFactorDimItem.RiskFactorDimTypeID == dimension.RiskFactorDimensionDetail.RiskFactorDimTypeID).First();
            locusDimItem = new ScenarioLocusDimItem() { RiskFactorDimItem = dimItem.RiskFactorDimItem, StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-200), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            locus.ScenarioLocusDimItems.Add(locusDimItem);
        }
Ejemplo n.º 2
0
        public Scenario DeepCopy(Scenario scenario, string scenarioName = "")
        {
            Scenario copyScenario = new Scenario();
            Context.Scenarios.Add(copyScenario);

            //copy values from original and reset audit
            Context.Entry(copyScenario).CurrentValues.SetValues(scenario);
            copyScenario.Default(Context.UserName);

            ScenarioDetail copyDetail = new ScenarioDetail();
            Context.ScenarioDetails.Add(copyDetail);

            Context.Entry(copyDetail).CurrentValues.SetValues(scenario.ScenarioDetail);
            copyDetail.Default(Context.UserName);
            copyDetail.Name = scenarioName;

            copyScenario.ScenarioDetails.Add(copyDetail);

            //copy locuses
            foreach (ScenarioLocus locus in scenario.ScenarioDetail.ScenarioLocuses.ToList())
            {
                ScenarioLocus copyLocus = new ScenarioLocus();
                Context.ScenarioLocuses.Add(copyLocus);

                Context.Entry(copyLocus).CurrentValues.SetValues(locus);
                copyLocus.Default(Context.UserName);

                copyDetail.ScenarioLocuses.Add(copyLocus);

                //copy locus dim items
                foreach (ScenarioLocusDimItem dimItem in locus.ScenarioLocusDimItems.ToList())
                {
                    ScenarioLocusDimItem copyDimItem = new ScenarioLocusDimItem();
                    Context.ScenarioLocusDimItems.Add(copyDimItem);

                    Context.Entry(copyDimItem).CurrentValues.SetValues(dimItem);
                    copyDimItem.Default(Context.UserName);

                    copyLocus.ScenarioLocusDimItems.Add(copyDimItem);
                }

                //copy locus dim groups
                foreach (ScenarioLocusDimGroup dimGroup in locus.ScenarioLocusDimGroups.ToList())
                {
                    ScenarioLocusDimGroup copyDimGroup = new ScenarioLocusDimGroup();
                    Context.ScenarioLocusDimGroups.Add(copyDimGroup);

                    Context.Entry(copyDimGroup).CurrentValues.SetValues(dimGroup);
                    copyDimGroup.Default(Context.UserName);

                    copyLocus.ScenarioLocusDimGroups.Add(copyDimGroup);
                }
            }

            //copy points
            foreach (ScenarioPoint point in scenario.ScenarioDetail.ScenarioPoints.ToList())
            {
                ScenarioPoint copyPoint = new ScenarioPoint();
                Context.ScenarioPoints.Add(copyPoint);

                Context.Entry(copyPoint).CurrentValues.SetValues(point);
                copyPoint.Default(Context.UserName);

                copyDetail.ScenarioPoints.Add(copyPoint);

                //copy coordinates
                foreach (ScenarioPointCoordinate coordinate in point.ScenarioPointCoordinates.ToList())
                {
                    ScenarioPointCoordinate copyCoordinate = new ScenarioPointCoordinate();
                    Context.ScenarioPointCoordinates.Add(copyCoordinate);

                    Context.Entry(copyCoordinate).CurrentValues.SetValues(coordinate);
                    copyCoordinate.Default(Context.UserName);

                    copyPoint.ScenarioPointCoordinates.Add(copyCoordinate);
                }
            }

            //copy untis
            foreach (ScenarioUnit unit in scenario.ScenarioDetail.ScenarioUnits.ToList())
            {

                ScenarioUnit copyUnit = new ScenarioUnit();
                Context.ScenarioUnits.Add(copyUnit);

                Context.Entry(copyUnit).CurrentValues.SetValues(unit);
                copyUnit.Default(Context.UserName);

                copyDetail.ScenarioUnits.Add(copyUnit);

                //copy coordinates
                foreach (ScenarioUnitPoint unitPoint in unit.ScenarioUnitPoints.ToList())
                {
                    ScenarioUnitPoint copyUnitPoint = new ScenarioUnitPoint();
                    Context.ScenarioUnitPoints.Add(copyUnitPoint);

                    Context.Entry(copyUnitPoint).CurrentValues.SetValues(unitPoint);
                    copyUnitPoint.Default(Context.UserName);

                    copyUnit.ScenarioUnitPoints.Add(copyUnitPoint);
                }
            }

            return copyScenario;
        }
Ejemplo n.º 3
0
        private static void AddScenarioLocuses3(ScenarioGeneratorModel context)
        {
            DateTime now = context.AsOfDate;

            ScenarioDetail scenario = context.ScenarioDetails.Where(x => x.Name == "FX Volatility").First();

            ScenarioLocus locus;
            RiskFactorDimItemDetail dimItem;
            ScenarioLocusDimItem locusDimItem;
            ScenarioLocusDimGroup locusDimGroup;

            RiskFactorDimension dimension = scenario.RiskFactorType.RiskFactorTypeDimensions.Where(d => d.RiskFactorDimension.RiskFactorDimensionDetail.Name == "Currency").First().RiskFactorDimension;

            locus = new ScenarioLocus() { ScenarioDetailID = scenario.ScenarioDetailID, StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-200), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            locus.RiskFactorDimension = dimension;
            scenario.ScenarioLocuses.Add(locus);

            dimItem = context.RiskFactorDimItemDetails.Where(i => i.Name == "EUR" && i.RiskFactorDimItem.RiskFactorDimTypeID == dimension.RiskFactorDimensionDetail.RiskFactorDimTypeID).First();
            locusDimItem = new ScenarioLocusDimItem() { RiskFactorDimItem = dimItem.RiskFactorDimItem, StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-200), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            locus.ScenarioLocusDimItems.Add(locusDimItem);

            dimension = scenario.RiskFactorType.RiskFactorTypeDimensions.Where(d => d.RiskFactorDimension.RiskFactorDimensionDetail.Name == "Country of Origin").First().RiskFactorDimension;

            locus = new ScenarioLocus() { ScenarioDetailID = scenario.ScenarioDetailID, StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-200), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            locus.RiskFactorDimension = dimension;
            scenario.ScenarioLocuses.Add(locus);

            RiskFactorDimItemGroup dimGroup = context.RiskFactorDimItemGroups.Where(g => g.Name == "European Countries").First();
            locusDimGroup = new ScenarioLocusDimGroup() { RiskFactorDimGroup = dimGroup, StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-200), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            locus.ScenarioLocusDimGroups.Add(locusDimGroup);
        }
Ejemplo n.º 4
0
        public ScenarioLocus AddLocus(ScenarioDetail scenarioDetail)
        {
            ScenarioLocus locus = new ScenarioLocus();
            locus.Default(Context.UserName);

            if (Context.ScenarioLocuses.Count() > 0)
                locus.ScenarioLocusID = Context.ScenarioLocuses.Max(x => x.ScenarioLocusID) + 1;
            else
                locus.ScenarioLocusID = 1;

            scenarioDetail.ScenarioLocuses.Add(locus);

            if (scenarioDetail.Status == EntityStatus.Approved)
                scenarioDetail.Modified(Context.UserName);

            return locus;
        }