public void Update(T entity) { var attachedEntity = Entities.Local.FirstOrDefault(e => e.Id == entity.Id); if (attachedEntity != null) { _context.Entry(attachedEntity).State = EntityState.Detached; } Entities.Attach(entity); _context.Entry(entity).State = EntityState.Modified; }
public int Edit(Dto.ApplicationUser user) { var userModel = _db.Users.Single(u => u.Id == user.Id); userModel.NameSurname = user.NameSurname; //userModel.Email = user.Email; //userModel.PhoneNumber = user.PhoneNumber; //userModel.Status = user.Status; _db.Entry(userModel).State = System.Data.Entity.EntityState.Modified; return(_db.SaveChanges()); }