private void OnChangeUser(User user) { if (ChangeUser == null) return; var ok = ChangeUser(user); if (!ok) { throw new ApplicationException("User has not been updated"); } }
private void OnAddUser(User user) { if (AddUser == null) return; var ok = AddUser(user); if (!ok) { throw new ApplicationException("User has not been added"); } }
public User AddOrUpdate(User user) { using (var connection = new ReferenceDataEntities()) { User oldValue = connection.Users.FirstOrDefault(x => x.Id == user.Id); if (oldValue != null) { connection.Entry(oldValue).CurrentValues.SetValues(user); connection.SaveChanges(); return null; } else { connection.Users.Add(user); connection.SaveChanges(); return user; } } }
bool view_ChangeUser(User userToUpdate) { return model.UpdateUser(userToUpdate); }
bool view_AddUser(User userToAdd) { return model.UpdateUser(userToAdd); }
internal bool UpdateUser(User userToUpdate) { return userService.AddOrUpdate(userToUpdate); }