Beispiel #1
0
        private void OnChangeUser(User user)
        {
            if (ChangeUser == null) return;

            var ok = ChangeUser(user);
            if (!ok)
            {
                throw new ApplicationException("User has not been updated");
            }
        }
Beispiel #2
0
        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;
         }
     }
 }
Beispiel #4
0
 bool view_ChangeUser(User userToUpdate)
 {
     return model.UpdateUser(userToUpdate);
 }
Beispiel #5
0
 bool view_AddUser(User userToAdd)
 {
     return model.UpdateUser(userToAdd);
 }
Beispiel #6
0
 internal bool UpdateUser(User userToUpdate)
 {
     return userService.AddOrUpdate(userToUpdate);
 }