Exemple #1
0
        public override Guid SaveToDB()
        {
            using (var db = new Db.PhisioDB())
            {
                if (Id != null && Guid.Empty != Id)
                {
                    db.VisitsTreatments.Where(x => x.VisitId == Id).Delete();
                    foreach (var visitTreatment in Treatmentsvisitidfkeys)
                    {
                        visitTreatment.VisitId = Id;
                        db.Insert(visitTreatment);
                    }

                    db.Update(this);
                }
                else
                {
                    Id = Guid.NewGuid();
                    Id = Guid.Parse(db.InsertWithIdentity(this).ToString());
                    if (Treatmentsvisitidfkeys != null)
                    {
                        foreach (var visitTreatment in Treatmentsvisitidfkeys)
                        {
                            visitTreatment.Visit   = this;
                            visitTreatment.VisitId = Id;
                            db.Insert(visitTreatment);
                        }
                    }
                }
            }
            return(Id);
        }
Exemple #2
0
        }                                                                                  // uuid

        public void SaveToDB(Visit _visit)
        {
            using (var db = new Db.PhisioDB())
            {
                if (_visit.Id != null)
                {
                    db.VisitsTreatments.Where(x => x.VisitId == _visit.Id).Delete();
                    foreach (var visitTreatment in _visit.Treatmentsvisitidfkeys)
                    {
                        db.Insert(visitTreatment);
                    }

                    db.Update(_visit);
                }
                else
                {
                    _visit.Id = Guid.Parse(db.InsertWithIdentity(_visit).ToString());
                    if (_visit.Treatmentsvisitidfkeys != null)
                    {
                        foreach (var visitTreatment in _visit.Treatmentsvisitidfkeys)
                        {
                            visitTreatment.Visit   = _visit;
                            visitTreatment.VisitId = _visit.Id;
                            db.Insert(visitTreatment);
                        }
                    }
                }
            }
        }