public void DeleteUsers(DeleteUsersInput userDtos) { _userServiceImp.DeleteUsers(userDtos); }
public void DeleteUsers(DeleteUsersInput input) { if (input.Users == null) throw new ArgumentNullException("input"); foreach (var userDto in input.Users) { User user = null; if (!(userDto.Id == Guid.Empty)) user = _userRepository.Get(userDto.Id); else if (!string.IsNullOrEmpty(userDto.UserName)) user = _userRepository.Single(u => u.UserName == userDto.UserName); else if (!string.IsNullOrEmpty(userDto.Email)) user = _userRepository.Single(u => u.Email == userDto.Email); else throw new ArgumentNullException("input", "Either ID, UserName or Email should be specified."); var userRole = _userRoleRepository.Single(ur => ur.UserId == user.Id); if (userRole != null) _userRoleRepository.Delete(userRole); _userRepository.Delete(user); } }