예제 #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");
            }
        }
예제 #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");
            }
        }
예제 #3
0
 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;
         }
     }
 }
예제 #4
0
 bool view_ChangeUser(User userToUpdate)
 {
     return model.UpdateUser(userToUpdate);
 }
예제 #5
0
 bool view_AddUser(User userToAdd)
 {
     return model.UpdateUser(userToAdd);
 }
예제 #6
0
파일: Model.cs 프로젝트: marimano/TestApp
 internal bool UpdateUser(User userToUpdate)
 {
     return userService.AddOrUpdate(userToUpdate);
 }