public object Put(UserCreateUpdateRequest request) { if (request.Id == Guid.Empty || string.IsNullOrWhiteSpace(request.FirstName) || string.IsNullOrWhiteSpace(request.LastName) || string.IsNullOrWhiteSpace(request.EmailAddress)) { throw new ArgumentException("Id, FirstName, LastName, and EmailAddress are required."); } var user = new User { Id = request.Id, FirstName = request.FirstName, LastName = request.LastName, EmailAddress = request.EmailAddress }; var updatedUser = _userRepository.UpdateUser(user); if (updatedUser == null) { throw HttpError.NotFound("User not found."); } return(updatedUser); }
public object Post(UserCreateUpdateRequest request) { if (string.IsNullOrWhiteSpace(request.FirstName) || string.IsNullOrWhiteSpace(request.LastName) || string.IsNullOrWhiteSpace(request.EmailAddress)) { throw new ArgumentException("FirstName, LastName, and EmailAddress are required."); } var user = new User { Id = Guid.NewGuid(), FirstName = request.FirstName, LastName = request.LastName, EmailAddress = request.EmailAddress, CreatedDate = DateTime.UtcNow }; return(_userRepository.AddUser(user)); }