private Simulation <MaternityBenefitSimulationCase> ConvertFromDb(EFModels.Simulation dbRes) { return(new Simulation <MaternityBenefitSimulationCase>() { Id = dbRes.Id, Name = dbRes.Name, BaseCase = new MaternityBenefitSimulationCase(dbRes.BaseCase), VariantCase = new MaternityBenefitSimulationCase(dbRes.VariantCase), DateCreated = dbRes.CreateDate }); }
public void SaveSimulation(Simulation <MaternityBenefitSimulationCase> simulation) { // Save the base case var baseCaseId = Guid.NewGuid(); var baseCase = new EFModels.Case() { Id = baseCaseId, MaxWeeklyAmount = simulation.BaseCase.MaxWeeklyAmount, NumWeeks = simulation.BaseCase.NumWeeks, IsBase = true, Percentage = simulation.BaseCase.Percentage, }; _context.Cases.Add(baseCase); // Save the variant case var variantCaseId = Guid.NewGuid(); var variantCase = new EFModels.Case() { Id = variantCaseId, MaxWeeklyAmount = simulation.VariantCase.MaxWeeklyAmount, NumWeeks = simulation.VariantCase.NumWeeks, IsBase = false, Percentage = simulation.VariantCase.Percentage, }; _context.Cases.Add(variantCase); // Save the sim var savedSim = new EFModels.Simulation() { Id = simulation.Id, Name = simulation.Name, BaseCaseId = baseCaseId, VariantCaseId = variantCaseId, Status = 0, CreateDate = simulation.DateCreated, }; _context.Simulations.Add(savedSim); _context.SaveChanges(); }