示例#1
0
        public Employee RefreshEmployeeInfo(Employee employee)
        {
            if (!_context.Employees.Any(e => e.Id.Equals(employee.Id)))
            {
                return(null);
            }

            var result = _context.Employees.SingleOrDefault(e => e.Id.Equals(employee.Id));

            if (result != null)
            {
                try
                {
                    _context.Entry(result).CurrentValues.SetValues(employee);
                    _context.SaveChanges();
                    return(result);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
示例#2
0
        public User RefreshUserInfo(User user)
        {
            if (!_context.Users.Any(u => u.Id.Equals(user.Id)))
            {
                return(null);
            }

            var result = _context.Users.SingleOrDefault(p => p.Id.Equals(user.Id));

            if (result != null)
            {
                try
                {
                    _context.Entry(result).CurrentValues.SetValues(user);
                    _context.SaveChanges();
                    return(result);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
示例#3
0
        public Person Update(Person person)
        {
            if (!Exists(person.Id))
            {
                return(new Person());
            }

            var result = _context.People.SingleOrDefault(p => p.Id.Equals(person.Id));

            if (result != null)
            {
                try
                {
                    _context.Entry(result).CurrentValues.SetValues(person);
                    _context.SaveChanges();
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(person);
        }
 public void Update(UserAccount user)
 {
     db.Entry(user).State = EntityState.Modified;
 }
 public void Update(School school)
 {
     db.Entry(school).State = EntityState.Modified;
 }