public virtual NeisseriaPubMlstIsolate GetIsolateById(int id) { try { var isolateJson = JObject.Parse(callGetUrl($"{BaseUrl}/{id}")); var allelesJson = JObject.Parse(callGetUrl($"{BaseUrl}/{id}/allele_ids?return_all=1")); var alleles = ConvertToDictionary(allelesJson.GetValue("allele_ids")); var isolate = new NeisseriaPubMlstIsolate { PubMlstId = id, PorAVr1 = alleles.Get(PorAVr1, ""), PorAVr2 = alleles.Get(PorAVr2, ""), FetAVr = alleles.Get(FetAVr, ""), PorB = alleles.Get(PorB, ""), Fhbp = alleles.Get(Fhbp, ""), Nhba = alleles.Get(NhbaPeptide, ""), NadA = alleles.Get(NadaPeptide, ""), PenA = alleles.Get(PenA, ""), GyrA = alleles.Get(GyrA, ""), ParC = alleles.Get(Neis1525, ""), ParE = alleles.Get(Neis1600, ""), RpoB = alleles.Get(RpoB, ""), RplF = alleles.Get(RplF, ""), }; var fields = isolateJson.GetValue("schemes")?.First["fields"]; if (fields != null) { isolate.SequenceType = fields[SequenceType]?.Value <string>(); isolate.ClonalComplex = fields[ClonalComplex]?.Value <string>(); } var phenotypic = isolateJson["phenotypic"]; if (phenotypic != null) { isolate.BexseroReactivity = phenotypic.Value <string>(BexseroReactivity); isolate.TrumenbaReactivity = phenotypic.Value <string>(TrumenbaReactivity); } return(isolate); } catch (WebException e) { Log.Error(e, "$Failed to call PubMLST REST API."); return(null); } }
private NeisseriaPubMlstIsolate CreateOrUpdatePubMlstIsolate(MeningoIsolate isolate, NeisseriaPubMlstIsolate pubMlstIsolate) { //TODO fix this duplication from MeningoIsolateController and try to find a //mapping framework which does not mess with EntityFramework context as automapper var pubMlstIsolateFromDatabase = _db.NeisseriaPubMlstIsolates.SingleOrDefault(n => n.PubMlstId == pubMlstIsolate.PubMlstId); if (pubMlstIsolateFromDatabase == null) { pubMlstIsolateFromDatabase = pubMlstIsolate; _db.NeisseriaPubMlstIsolates.Add(pubMlstIsolateFromDatabase); } else { pubMlstIsolateFromDatabase.PorAVr1 = pubMlstIsolate.PorAVr1; pubMlstIsolateFromDatabase.PorAVr2 = pubMlstIsolate.PorAVr2; pubMlstIsolateFromDatabase.FetAVr = pubMlstIsolate.FetAVr; pubMlstIsolateFromDatabase.PorB = pubMlstIsolate.PorB; pubMlstIsolateFromDatabase.Fhbp = pubMlstIsolate.Fhbp; pubMlstIsolateFromDatabase.Nhba = pubMlstIsolate.Nhba; pubMlstIsolateFromDatabase.NadA = pubMlstIsolate.NadA; pubMlstIsolateFromDatabase.PenA = pubMlstIsolate.PenA; pubMlstIsolateFromDatabase.GyrA = pubMlstIsolate.GyrA; pubMlstIsolateFromDatabase.ParC = pubMlstIsolate.ParC; pubMlstIsolateFromDatabase.ParE = pubMlstIsolate.ParE; pubMlstIsolateFromDatabase.RpoB = pubMlstIsolate.RpoB; pubMlstIsolateFromDatabase.RplF = pubMlstIsolate.RplF; pubMlstIsolateFromDatabase.SequenceType = pubMlstIsolate.SequenceType; pubMlstIsolateFromDatabase.ClonalComplex = pubMlstIsolate.ClonalComplex; pubMlstIsolateFromDatabase.BexseroReactivity = pubMlstIsolate.BexseroReactivity; pubMlstIsolateFromDatabase.TrumenbaReactivity = pubMlstIsolate.TrumenbaReactivity; } isolate.NeisseriaPubMlstIsolate = pubMlstIsolateFromDatabase; return(pubMlstIsolateFromDatabase); }
public MeningoIsolateViewModel() { EpsilometerTestViewModels = new List <EpsilometerTestViewModel>(); NeisseriaPubMlstIsolate = new NeisseriaPubMlstIsolate(); Report = new string[0]; }