public void Add()
        {
            using (var ScenGenContext = new ScenarioGeneratorModel("UnitTestUser", Connection))
            {
                ScenGenContext.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                var record = new RiskFactorDimension();
                var item = new RiskFactorDimensionDetail();
                record.RiskFactorDimensionDetails.Add(item);
                item.Name = "XXX";

                 var dimType = new RiskFactorDimType();
                dimType.Name = "XXX";
                item.RiskFactorDimType = dimType;

                ScenGenContext.RiskFactorDimensionDetails.Add(item);
                ScenGenContext.SaveChanges();

                var result = ScenGenContext.RiskFactorDimensions.Include("RiskFactorDimType").Include("RiskFactorDimensionDetail").Where(x => x.RiskFactorDimensionDetail.Name == "XXX").ToList();

                Assert.AreEqual(1, result.Count());
                Assert.IsNotNull(result[0].RiskFactorDimensionDetail);
                Assert.IsNotNull(result[0].RiskFactorDimensionDetail.RiskFactorDimType);
            }
        }
 public OneDimVisualizationController(RiskFactorDimItemDetail[] items, RiskFactorDimension dim, List<ScenarioPointCoordinate> points)
 {
     list = new List<OneDimCoordinate>();
     Array.Sort(items); // first coordinate
     DimItems = items;
     Points = new List<ScenarioPointCoordinate>(points);
     Create();
 }
Example #3
0
        internal static void AddDimensions(ScenarioGeneratorModel context)
        {
            DateTime now = context.AsOfDate;

            var record = new RiskFactorDimension() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            var itemdimType = context.RiskFactorDimTypes.Where(x => x.Name == "Tenor").First();
            var item = new RiskFactorDimensionDetail() { Name = "Instrument Tenor", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            item.RiskFactorDimType = itemdimType;
            record.RiskFactorDimensionDetails.Add(item);
            context.RiskFactorDimensions.Add(record);

            record = new RiskFactorDimension() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            itemdimType = context.RiskFactorDimTypes.Where(x => x.Name == "Tenor").First();
            item = new RiskFactorDimensionDetail() { Name = "Underlying Tenor", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            item.RiskFactorDimType = itemdimType;
            record.RiskFactorDimensionDetails.Add(item);
            context.RiskFactorDimensions.Add(record);

            record = new RiskFactorDimension() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            itemdimType = context.RiskFactorDimTypes.Where(x => x.Name == "Country").First();
            item = new RiskFactorDimensionDetail() { Name = "Country of Risk", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            item.RiskFactorDimType = itemdimType;
            record.RiskFactorDimensionDetails.Add(item);
            context.RiskFactorDimensions.Add(record);

            record = new RiskFactorDimension() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            itemdimType = context.RiskFactorDimTypes.Where(x => x.Name == "Currency").First();
            item = new RiskFactorDimensionDetail() { Name = "Currency", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            item.RiskFactorDimType = itemdimType;
            record.RiskFactorDimensionDetails.Add(item);
            context.RiskFactorDimensions.Add(record);

            record = new RiskFactorDimension() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            itemdimType = context.RiskFactorDimTypes.Where(x => x.Name == "Currency").First();
            item = new RiskFactorDimensionDetail() { Name = "Underlying Currency", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            item.RiskFactorDimType = itemdimType;
            record.RiskFactorDimensionDetails.Add(item);
            context.RiskFactorDimensions.Add(record);

            record = new RiskFactorDimension() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            itemdimType = context.RiskFactorDimTypes.Where(x => x.Name == "Country").First();
            item = new RiskFactorDimensionDetail() { Name = "Country of Origin", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            item.RiskFactorDimType = itemdimType;
            record.RiskFactorDimensionDetails.Add(item);
            context.RiskFactorDimensions.Add(record);

            record = new RiskFactorDimension() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            itemdimType = context.RiskFactorDimTypes.Where(x => x.Name == "Region").First();
            item = new RiskFactorDimensionDetail() { Name = "Region of Risk", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            item.RiskFactorDimType = itemdimType;
            record.RiskFactorDimensionDetails.Add(item);
            context.RiskFactorDimensions.Add(record);

            record = new RiskFactorDimension() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            itemdimType = context.RiskFactorDimTypes.Where(x => x.Name == "Rating").First();
            item = new RiskFactorDimensionDetail() { Name = "Obligor Rating", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            item.RiskFactorDimType = itemdimType;
            record.RiskFactorDimensionDetails.Add(item);
            context.RiskFactorDimensions.Add(record);

            record = new RiskFactorDimension() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            itemdimType = context.RiskFactorDimTypes.Where(x => x.Name == "Sector").First();
            item = new RiskFactorDimensionDetail() { Name = "Instrument Sector", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            item.RiskFactorDimType = itemdimType;
            record.RiskFactorDimensionDetails.Add(item);
            context.RiskFactorDimensions.Add(record);

            record = new RiskFactorDimension() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            itemdimType = context.RiskFactorDimTypes.Where(x => x.Name == "Sector").First();
            item = new RiskFactorDimensionDetail() { Name = "Underlying Sector", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true };
            item.RiskFactorDimType = itemdimType;
            record.RiskFactorDimensionDetails.Add(item);
            context.RiskFactorDimensions.Add(record);

            context.SaveChanges();
        }
 public TwoDimVisualizationController(RiskFactorDimItemDetail[] dimMajorItems, RiskFactorDimension majorDim, RiskFactorDimItemDetail[] dimMinorItems, RiskFactorDimension minorDim, List<ScenarioPointCoordinate> points)
 {
     array2D = new TwoDimCoordinate[dimMajorItems.Length, dimMinorItems.Length];
     Array.Sort(dimMajorItems); // first coordinate
     Array.Sort(dimMinorItems); // second coordinate
     DimMajorItems = dimMajorItems;
     DimMinorItems = dimMinorItems;
     Points = new List<ScenarioPointCoordinate>( points);
     Create();
 }