Example #1
0
        protected void SetEntitiesState(IkeMedContext context, Person person)
        {
            if (person != null)
            {
                var personEntry = context.Entry(person);
                if (personEntry.State == EntityState.Detached)
                {
                    context.People.Attach(person);
                }

                context.Entry(person).State = person.ID > 0 ? EntityState.Modified : EntityState.Added;
                if (person.Doctor != null)
                {
                    context.Entry(person.Doctor).State = person.Doctor.ID > 0 ? EntityState.Modified : EntityState.Added;
                }
                if (person.LegalPerson != null)
                {
                    context.Entry(person.LegalPerson).State = person.LegalPerson.ID > 0 ? EntityState.Modified : EntityState.Added;
                }
                if (person.NaturalPerson != null)
                {
                    context.Entry(person.NaturalPerson).State = person.NaturalPerson.ID > 0 ? EntityState.Modified : EntityState.Added;
                }
            }

            base.SetEntitiesState(context);
        }
Example #2
0
        public override int SaveChanges(IkeMedContext context)
        {
            this.SetEntitiesState(context);
            this.SaveImages();

            return(base.SaveChanges(context));
        }
Example #3
0
 protected override void SetEntitiesState(IkeMedContext context)
 {
     if (this != null)
     {
         context.Entry(this).State = this.ID > 0 ? EntityState.Modified : EntityState.Added;
         if (this.Person != null)
         {
             context.Entry(this.Person).State = this.Person != null && this.Person.ID > 0
                                                     ? EntityState.Modified : EntityState.Added;
         }
     }
 }
 protected override void SetEntitiesState(IkeMedContext context)
 {
     if (this != null)
     {
         context.Entry(this).State = this.ID > 0 ? EntityState.Modified : EntityState.Added;
         if (this.Documents != null)
         {
             context.Entry(this.Documents).State = this.Documents != null && this.Documents.Count > 0
                                                     ? EntityState.Modified : EntityState.Added;
         }
     }
 }
Example #5
0
        protected override void SetEntitiesState(IkeMedContext context)
        {
            if (this != null)
            {
                context.Entry(this).State = this.ID > 0 ? EntityState.Modified : EntityState.Added;
                if (this.Doctor != null)
                {
                    context.Entry(this.Doctor).State = this.Doctor.ID > 0 ? EntityState.Modified : EntityState.Added;
                }
                if (this.LegalPerson != null)
                {
                    context.Entry(this.LegalPerson).State = this.LegalPerson.ID > 0 ? EntityState.Modified : EntityState.Added;
                }
                if (this.NaturalPerson != null)
                {
                    context.Entry(this.NaturalPerson).State = this.NaturalPerson.ID > 0 ? EntityState.Modified : EntityState.Added;
                }
            }

            base.SetEntitiesState(context);
        }
Example #6
0
        public int SaveChanges(IkeMedContext context, Person person)
        {
            this.SetEntitiesState(context, person);

            return(context.SaveChanges());
        }
Example #7
0
 public virtual int SaveChanges(IkeMedContext context)
 {
     return(context.SaveChanges());
 }
Example #8
0
 protected virtual void SetEntitiesState(IkeMedContext context)
 {
 }