public HomeController(UserByIdQuery userByIdQuery, IServiceFactory factory, IProcess<ByUserIdParams, VisibleOrgOfficialDocListForUserViewModel> userVisibleDocProcess) { _userByIdQuery = userByIdQuery; _serviceFactory = factory; _unitOfWork = factory.GetService<IUnitOfWork>(); _userVisibleDocsProcess = userVisibleDocProcess; }
public MilestoneController(IProcess <ByOrganizationIdParams, MilestoneDisplayListViewModel> milestoneListQuery, IProcess <MilestoneIdParams, MilestoneDisplayViewModel> milestoneQuery, IProcess <SaveMilestoneParams, MilestoneIdViewModel> saveMilestoneProcess, UserByIdQuery userByIdQuery) { _milestoneListQuery = milestoneListQuery; _userByIdQuery = userByIdQuery; _milestoneQuery = milestoneQuery; _saveMilestoneProcess = saveMilestoneProcess; }
public async Task <UserVm> Handle(UserByIdQuery query, CancellationToken cancellationToken) { var user = await _userRepository.FindAsync(x => x.Id == query.Id); if (user != null) { return(user.ToVm()); } Notifications.Handle("Usuario Não encontrado"); return(null); }
public User GetUser(Guid userId) { var query = new UserByIdQuery(dbContext.Users); var user = query.Execute(userId); if (user == null) { throw new EntityNotFoundException("User", userId); } return(new UserMapper().Map(query.Execute(userId))); }
public CompanyController(IUnitOfWork unitOfWork, ISearchProvider searchProvider, IServiceFactory serviceFactory, UserByIdQuery userByIdQuery, IProcess<CompanyQueryAuthorizationParams, AuthorizationResultViewModel> compAuthProcess) { _unitOfWork = unitOfWork; _searchProvider = searchProvider; _serviceFactory = serviceFactory; _companyAuthProcess = compAuthProcess; _userByIdQuery = userByIdQuery; }
public User GetUser(Guid id) { var query = new UserByIdQuery(dbContext.Users); var user = query.Execute(id); if (user == null) { throw new EntityNotFoundException("User", id); } return(user); }
public CompanyController(IUnitOfWork unitOfWork, ISearchProvider searchProvider, IServiceFactory serviceFactory, UserByIdQuery userByIdQuery, IProcess <CompanyQueryAuthorizationParams, AuthorizationResultViewModel> compAuthProcess) { _unitOfWork = unitOfWork; _searchProvider = searchProvider; _serviceFactory = serviceFactory; _companyAuthProcess = compAuthProcess; _userByIdQuery = userByIdQuery; }
public void Execute_Returns_Null_User_When_UserId_Not_Found() { // Setup InitializeTestEntities(); int id = _user.Id + 100; // Act User result = new UserByIdQuery(_unitOfWork).WithUserId(id).Execute(); // Verify Assert.IsNull(result, "Query returned a non-null user"); }
public void Can_Retrieve_User_By_Id() { // Setup InitializeTestEntities(); // Act User result = new UserByIdQuery(_unitOfWork).WithUserId(_user.Id).Execute(); // Verify Assert.IsNotNull(result, "User returned was null"); Assert.AreEqual(result.Id, _user.Id, "User returned had an incorrect id value"); }
public async Task<IActionResult> Get(UserModel userModel) { var identifier = User.FindFirstValue(ClaimTypes.NameIdentifier); if (string.IsNullOrEmpty(identifier)) { return BadRequest(); } var query = new UserByIdQuery(Guid.Parse(identifier)); var user = await _messageDispatcher.Execute(query); return Json(user); }
public async Task <IActionResult> Get(UserModel userModel) { var identifier = User.FindFirstValue(ClaimTypes.NameIdentifier); if (string.IsNullOrEmpty(identifier)) { return(HttpBadRequest()); } var query = new UserByIdQuery(Guid.Parse(identifier)); var user = await _messageDispatcher.Execute(query); return(Json(user)); }
public IActionResult GetUserAsync() { try { var query = new UserByIdQuery(17); var user = _queryProcessor.Process(query); return(new OkObjectResult(user)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <RequestResult <UserResponse> > Handle(UserByIdQuery request, CancellationToken cancellationToken) { try { var user = await _ctx.Users.FirstOrDefaultAsync(x => x.Id == request.Id); if (user == null) { return(RequestResult.Error <UserResponse>()); } var response = _mapper.Map <UserResponse>(user); return(RequestResult.Success(response)); } catch (Exception ex) { _logger.LogError("Error getting user", ex); return(RequestResult.Error <UserResponse>()); } }
/// <summary> /// Executes the command /// </summary> /// <returns></returns> /// <exception cref="MJLEntityNotFoundException">Thrown when the specified user isn't found</exception> public virtual User Execute() { // Retrieve the user var user = new UserByIdQuery(_unitOfWork).WithUserId(_userId).Execute(); if (user == null) { throw new MJLEntityNotFoundException(typeof(User), _userId); } // Only check the current password if the user is only changing the last visited job search if (!string.IsNullOrWhiteSpace(_newPassword) || !string.IsNullOrWhiteSpace(_newName)) { // Verify the user's current password is correct if (new UserByCredentialsQuery(_unitOfWork).WithEmail(user.Email).WithPassword(_oldPassword).Execute() == null) { throw new MJLIncorrectPasswordException(_userId); } } // Edit the properties if (!string.IsNullOrWhiteSpace(_newPassword)) { user.Password = PasswordUtils.CreatePasswordHash(user.Email, _newPassword); } if (_newName != null) { user.FullName = _newName.Trim(); } if (_updateLastJobSearch) { user.LastVisitedJobSearchId = _lastJobSearchId; } // Save _unitOfWork.Commit(); return(user); }
public JobSearchController(JobSearchesByUserIdQuery jobSearchesByIdQuery, JobSearchByIdQuery jobSearchByIdQuery, CreateJobSearchForUserCommand createJobSearchCommand, EditJobSearchCommand editJobSearchCommand, OpenTasksByJobSearchQuery openTasksByJobSearchQuery, EditUserCommand editUserCommand, EntitySearchQuery entitySearchQuery, UserByIdQuery userByIdQuery, StartNextJobSearchMilestoneCommand startNextMilestoneCmd, IProcess <ByJobSearchParams, JobsearchExportViewModel> exportProcess, IServiceFactory serviceFactory) { _jobSearchByIdQuery = jobSearchByIdQuery; _jobSearchesByUserIdQuery = jobSearchesByIdQuery; _createJobSearchCommand = createJobSearchCommand; _editJobSearchCommand = editJobSearchCommand; _openTasksByJobSearchQuery = openTasksByJobSearchQuery; _editUserCommand = editUserCommand; _entitySearchQuery = entitySearchQuery; _serviceFactory = serviceFactory; _userByIdQuery = userByIdQuery; _startNextMilestoneCmd = startNextMilestoneCmd; _exportProcess = exportProcess; }
public JobSearchController(JobSearchesByUserIdQuery jobSearchesByIdQuery, JobSearchByIdQuery jobSearchByIdQuery, CreateJobSearchForUserCommand createJobSearchCommand, EditJobSearchCommand editJobSearchCommand, OpenTasksByJobSearchQuery openTasksByJobSearchQuery, EditUserCommand editUserCommand, EntitySearchQuery entitySearchQuery, UserByIdQuery userByIdQuery, StartNextJobSearchMilestoneCommand startNextMilestoneCmd, IProcess<ByJobSearchParams, JobsearchExportViewModel> exportProcess, IServiceFactory serviceFactory) { _jobSearchByIdQuery = jobSearchByIdQuery; _jobSearchesByUserIdQuery = jobSearchesByIdQuery; _createJobSearchCommand = createJobSearchCommand; _editJobSearchCommand = editJobSearchCommand; _openTasksByJobSearchQuery = openTasksByJobSearchQuery; _editUserCommand = editUserCommand; _entitySearchQuery = entitySearchQuery; _serviceFactory = serviceFactory; _userByIdQuery = userByIdQuery; _startNextMilestoneCmd = startNextMilestoneCmd; _exportProcess = exportProcess; }
/// <summary> /// Executes the command /// </summary> /// <returns></returns> /// <exception cref="MJLEntityNotFoundException">Thrown when the specified user isn't found</exception> public virtual User Execute() { // Retrieve the user var user = new UserByIdQuery(_unitOfWork).WithUserId(_userId).Execute(); if (user == null) throw new MJLEntityNotFoundException(typeof(User), _userId); // Only check the current password if the user is only changing the last visited job search if (!string.IsNullOrWhiteSpace(_newPassword) || !string.IsNullOrWhiteSpace(_newName)) { // Verify the user's current password is correct if (new UserByCredentialsQuery(_unitOfWork).WithEmail(user.Email).WithPassword(_oldPassword).Execute() == null) throw new MJLIncorrectPasswordException(_userId); } // Edit the properties if (!string.IsNullOrWhiteSpace(_newPassword)) user.Password = PasswordUtils.CreatePasswordHash(user.Email, _newPassword); if (_newName != null) { user.FullName = _newName.Trim(); } if (_updateLastJobSearch) { user.LastVisitedJobSearchId = _lastJobSearchId; } // Save _unitOfWork.Commit(); return user; }
/// <summary> /// Executes the command /// </summary> /// <returns></returns> /// <exception cref="MJLEntityNotFoundException">Thrown when the specified job search is not found</exception> public virtual JobSearch Execute() { // Retrieve the job search var search = new JobSearchByIdQuery(_unitOfWork).WithJobSearchId(_jobSearchId).Execute(); if (search == null) throw new MJLEntityNotFoundException(typeof(JobSearch), _jobSearchId); // Retrieve the calling user var user = new UserByIdQuery(_unitOfWork).WithUserId(_userId).Execute(); if (user == null) throw new MJLEntityNotFoundException(typeof(User), _userId); // Only edit the properties that were requested if (_newName != null) search.Name = _newName; if (_newDesc != null) search.Description = _newDesc; if (_resetHiddenStatusList) search.HiddenCompanyStatuses = string.Empty; // Append to the hidden company status list if (_hiddenStatuses.Count > 0) foreach (string status in _hiddenStatuses) search.HiddenCompanyStatuses += status + ";"; // Create the history record search.History.Add(new JobSearchHistory { HistoryAction = MJLConstants.HistoryUpdate, DateModified = DateTime.Now, AuthoringUser = user, Name = search.Name, Description = search.Description, HiddenCompanyStatuses = search.HiddenCompanyStatuses }); // Commit _unitOfWork.Commit(); return search; }
public Task <IActionResult> GetUserById(UserByIdQuery query) => ExecuteQuery(query);
public async Task <Optional <User> > RunAsync(UserByIdQuery query, CancellationToken ct) => Optional.FromNullable(await _db.Set <User>().FindAsync(new object[] { query.UserId }, ct));