public bool SaveSepsisResult(string encounterID, SepsisResult sepsisResult) { bool canSave = false; Guid encounterIdGuid = Guid.Parse(encounterID); using (_treatSepsisContext = new TreatSepsisEntities()) { var mortyResult = (from a in _treatSepsisContext.tMortyResult where a.EncounterID == encounterIdGuid select a); foreach (var result in mortyResult) { _treatSepsisContext.tMortyResult.Remove(result); } try { _treatSepsisContext.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); canSave = false; } tMortyResult res = new tMortyResult { MortyResultID = Guid.NewGuid(), EncounterID = encounterIdGuid, CalibrationDatabaseVersion = null, MortyVersion = null, HuginVersion = null, OverallProbabilityOfMortality = -1f, SepsisProbabilityNo = sepsisResult.No, SepsisProbabilityMild = sepsisResult.Mild, SepsisProbabilityModerate = sepsisResult.Moderate, SepsisProbabilitySevere = sepsisResult.Severe, SepsisProbabilityCritical = sepsisResult.Critical, OverallProbabilityOfBacteremia = sepsisResult.Bacterimia }; _treatSepsisContext.tMortyResult.Add(res); try { _treatSepsisContext.SaveChanges(); canSave = true; } catch (Exception e) { Console.WriteLine(e); canSave = false; } return canSave; } }