private SimulationResult ConvertFromDb(EFModels.SimulationResult dbRes) { return(new SimulationResult() { PersonResults = dbRes.PersonResults.Select(x => new PersonResult() { Person = new MaternityBenefitPerson(x.Person), BaseAmount = x.BaseAmount, VariantAmount = x.VariantAmount, } ).ToList() }); }
public void StoreResults(Guid simulationId, SimulationResult simulationResult) { var resultId = Guid.NewGuid(); var simResult = new EFModels.SimulationResult() { Id = resultId, SimulationId = simulationId }; _context.SimulationResults.Add(simResult); // Need to update the sim itself var sim = _context.Simulations .First(x => x.Id == simulationId); //sim.SimulationResultId = resultId; sim.Status = 1; _context.Simulations.Update(sim); var personResultsDb = simulationResult.PersonResults.Select(x => new EFModels.PersonResult() { Id = Guid.NewGuid(), PersonId = x.Person.Id, SimulationResultId = resultId, BaseAmount = x.BaseAmount, VariantAmount = x.VariantAmount, } ); foreach (var pr in personResultsDb) { _context.PersonResults.Add(pr); } _context.SaveChanges(); }