Ejemplo n.º 1
0
        public QUESTOR Edit(QUESTOR questor)
        {
            db.Entry(questor).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                foreach (var entry in ex.Entries)
                {
                    if (entry.Entity is QUESTOR)
                    {
                        var databaseEntity = db.QUESTORs
                                             .FirstOrDefault(m => m.QUESTORId == ((QUESTOR)entry.Entity).QUESTORId);
                        var databaseEntry = db.Entry(databaseEntity);

                        foreach (var property in entry.Metadata.GetProperties())
                        {
                            var proposedValue = entry.Property(property.Name).CurrentValue;
                            var originalValue = entry.Property(property.Name).OriginalValue;
                            var databaseValue = databaseEntry.Property(property.Name).CurrentValue;

                            entry.Property(property.Name).OriginalValue = databaseEntry.Property(property.Name).CurrentValue;
                        }
                    }
                    else
                    {
                        throw new NotSupportedException("Don't know how to handle concurrency conflicts for " + entry.Metadata.Name);
                    }

                    db.SaveChanges();
                }
            }

            return(questor);
        }
Ejemplo n.º 2
0
 public void Remove(QUESTOR questor)
 {
     db.QUESTORs.Remove(questor);
     db.SaveChanges();
 }
Ejemplo n.º 3
0
 public QUESTOR Save(QUESTOR questor)
 {
     db.QUESTORs.Add(questor);
     db.SaveChanges();
     return(questor);
 }