Пример #1
0
        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();
            }
        }
Пример #2
0
        public void CreateDuplex(Duplex duplex)
        {
            if (!IsDuplexExists(duplex))
            {
                duplex.MW = duplex.AntiSenseStrand.MW + duplex.SenseStrand.MW;
                duplex.AntiSenseStrand  = null;
                duplex.SenseStrand      = null;
                duplex.Target           = null;
                _db.Entry(duplex).State = EntityState.Added;
                _db.SaveChanges();

                duplex.DuplexId         = GetNextDuplexId(duplex.Id);
                _db.Entry(duplex).State = EntityState.Modified;
                _db.SaveChanges();
            }
        }