public void CreateStrand(Strand strand) { if (!IsStrandExists(strand)) { // TODO: implement right way to handle relations between objects. var orientation = strand.Orientation.Name; strand.Target = null; strand.Orientation = null; PopulateSpecies(strand); PopulateModStructures(strand); _db.SetEntityStateAdded(strand); _db.SaveChanges(); // todo: PH (after addition of StrandModStructure table) //item.MW = CalculateMW(item.BaseSequence, item.Sequence); //item.ExtinctionCoefficient = CalculateEC(item.BaseSequence, item.Sequence); foreach (var modStructure in strand.StrandModStructures) { _db.Entry(modStructure).Reference(c => c.ModStructure).Load(); } strand.CalculateMW(); strand.CalculateEC(); strand.BuildSequence(); strand.BuildBaseSequence(); strand.StrandId = GetNextStrandId(strand.Id, orientation); _db.SetEntityStateModified(strand); _db.SaveChanges(); } }
public void UpdateStrand(Strand strand) { if (!IsStrandExists(strand)) { var orientation = strand.Orientation.Name; strand.StrandId = GetUpdatedStrandId(strand.StrandId, orientation); strand.CalculateMW(); strand.CalculateEC(); strand.BuildSequence(); strand.BuildBaseSequence(); strand.Orientation = null; strand.Target = null; PopulateSpecies(strand); PopulateModStructures(strand); _db.SetEntityStateModified(strand); _db.SaveChanges(); } }