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(); } }
public void MergeStrand(Strand strand) { var strandId = strand.Id; strand.Id = 0; if (!IsStrandExists(strand)) { var sourceStrand = GetStrand(strandId); if (sourceStrand != null) { strand.ExtinctionCoefficient = sourceStrand.ExtinctionCoefficient; strand.GenomeNumber = sourceStrand.GenomeNumber; strand.GenomePosition = sourceStrand.GenomePosition; strand.MW = sourceStrand.MW; strand.Notes = sourceStrand.Notes; strand.OrientationId = sourceStrand.Orientation.Id; strand.ParentSequence = sourceStrand.ParentSequence; strand.TargetId = sourceStrand.Target.Id; strand.Species = sourceStrand.Species; _db.SetEntityStateAdded(strand); _db.SaveChanges(); foreach (var modStructure in strand.StrandModStructures) { _db.Entry(modStructure).Reference(a => a.ModStructure).Load(); } strand.BuildSequence(); strand.BuildBaseSequence(); strand.StrandId = GetNextStrandId(strand.Id, strand.Orientation.Name); _db.SetEntityStateModified(strand); _db.SaveChanges(); } } }