示例#1
0
        public SimulationModel CreateSimulation(CreateSimulationDataModel model, BridgeCareContext db)
        {
            var simulation = new SimulationEntity(model);

            db.Simulations.Add(simulation);

            db.SaveChanges();

            simulation = db.Simulations.Include(s => s.NETWORK)
                         .Single(s => s.SIMULATIONID == simulation.SIMULATIONID);

            return(new SimulationModel(simulation));
        }
示例#2
0
        public SimulationModel CreateSimulation(CreateSimulationDataModel model, BridgeCareContext db)
        {
            var simulation = new SimulationEntity(model);

            db.Simulations.Add(simulation);

            db.SaveChanges();

            var defaultBudgets = new List <string> {
                "Rehabilitation", "Maintenance", "Construction"
            };

            PriorityDAL.SavePriorityFundInvestmentData(simulation.SIMULATIONID, defaultBudgets, db);

            simulation = db.Simulations.Include(s => s.NETWORK)
                         .Single(s => s.SIMULATIONID == simulation.SIMULATIONID);

            return(new SimulationModel(simulation));
        }
示例#3
0
 public IHttpActionResult CreateSimulation([FromBody] CreateSimulationDataModel model) =>
 Ok(repo.CreateSimulation(model, db));
示例#4
0
        public SimulationEntity(CreateSimulationDataModel model)
        {
            NETWORKID         = model.NetworkId;
            SIMULATION        = model.Name;
            OWNER             = model.Owner;
            CREATOR           = model.Creator;
            DATE_CREATED      = DateTime.Now;
            ANALYSIS          = "Incremental Benefit/Cost";
            BUDGET_CONSTRAINT = "As Budget Permits";
            WEIGHTING         = "none";
            COMMITTED_START   = DateTime.Now.Year;
            COMMITTED_PERIOD  = 1;
            PRIORITIES        = new List <PriorityEntity>
            {
                new PriorityEntity
                {
                    PRIORITYLEVEL = 1,
                    YEARS         = null,
                    CRITERIA      = "",
                    PRIORITYFUNDS = new List <PriorityFundEntity>
                    {
                        new PriorityFundEntity {
                            BUDGET = "Rehabilitation", FUNDING = 100
                        },
                        new PriorityFundEntity {
                            BUDGET = "Maintenance", FUNDING = 100
                        },
                        new PriorityFundEntity {
                            BUDGET = "Construction", FUNDING = 100
                        }
                    }
                }
            };
            YEARLYINVESTMENTS = new List <YearlyInvestmentEntity>
            {
                new YearlyInvestmentEntity
                {
                    YEAR_      = DateTime.Now.Year,
                    BUDGETNAME = "Rehabilitation",
                    AMOUNT     = 5000000
                },
                new YearlyInvestmentEntity
                {
                    YEAR_      = DateTime.Now.Year,
                    BUDGETNAME = "Maintenance",
                    AMOUNT     = 5000000
                },
                new YearlyInvestmentEntity
                {
                    YEAR_      = DateTime.Now.Year,
                    BUDGETNAME = "Construction",
                    AMOUNT     = 5000000
                }
            };

            TREATMENTS = new List <TreatmentsEntity>
            {
                new TreatmentsEntity()
                {
                    TREATMENT           = "No Treatment",
                    BEFOREANY           = 1,
                    BEFORESAME          = 1,
                    BUDGET              = "Construction,Maintenance,Rehabilitation",
                    DESCRIPTION         = "Default Treatment",
                    OMS_IS_EXCLUSIVE    = null,
                    OMS_IS_REPEAT       = null,
                    OMS_REPEAT_START    = null,
                    OMS_REPEAT_INTERVAL = null,
                    FEASIBILITIES       = new List <FeasibilityEntity>
                    {
                        new FeasibilityEntity
                        {
                            CRITERIA = ""
                        }
                    },
                    CONSEQUENCES = new List <ConsequencesEntity>
                    {
                        new ConsequencesEntity
                        {
                            ATTRIBUTE_ = "AGE",
                            CHANGE_    = "+1"
                        }
                    }
                }
            };

            INVESTMENTS = new InvestmentsEntity()
            {
                FIRSTYEAR     = DateTime.Now.Year,
                NUMBERYEARS   = 1,
                INFLATIONRATE = 0,
                DISCOUNTRATE  = 0,
                BUDGETORDER   = "Rehabilitation,Maintenance,Construction"
            };

            CriteriaDrivenBudgets = new List <CriteriaDrivenBudgetEntity>
            {
                new CriteriaDrivenBudgetEntity
                {
                    BUDGET_NAME = "Maintenance",
                    CRITERIA    = ""
                },
                new CriteriaDrivenBudgetEntity
                {
                    BUDGET_NAME = "Rehabilitation",
                    CRITERIA    = ""
                },
                new CriteriaDrivenBudgetEntity
                {
                    BUDGET_NAME = "Construction",
                    CRITERIA    = ""
                }
            };

            USERS = new List <SimulationUserEntity>();
        }