public AbsenceSchedulingRequestQueryResult RequestAbsence(string id) { var query = new AbsenceSchedulingRequestQuery(); query.Id = id; return(_queryDispatcher.Dispatch <AbsenceSchedulingRequestQuery, AbsenceSchedulingRequestQueryResult>(query)); }
public async Task <PersonDto> Get(int id) { return(await _queryDispatcher.Dispatch <GetPerson.Query, PersonDto>(new GetPerson.Query { Id = id })); }
private void LoadDatabaseExecute() { var loadQuery = new LoadDataForListViewQuery(); var databaseInfoQuery = new GetCurrentDatabaseConnectionQuery(); _queryDispatcher.Dispatch <LoadDataForListViewQuery, Result <List <Worker> > >(loadQuery) .Tap(result => { var personModels = _mapper.Map <List <PersonModel> >(result); foreach (var personModel in personModels) { Persons.Add(_personViewModelFunc(personModel)); } IsChecked = true; ItemCount = Persons.Count; }) .Tap(() => { _queryDispatcher.Dispatch <GetCurrentDatabaseConnectionQuery, Result <string> >(databaseInfoQuery) .Tap(data => DatabaseConnectionPath = data); }) .Tap(result => { _messageDialogFunc().ShowUserMessage(GetType().Name, $" Loaded {result.Count} items"); }) .OnFailure(details => _messageDialogFunc().ShowErrorMessage(GetType().Name, "Error while loading database", details)); }
public async Task <GetOrder.Result> Get(int id) { return(await _queryDispatcher.Dispatch <GetOrder.Query, GetOrder.Result>(new GetOrder.Query() { ID = id })); }
public AddJourneyWithLiftsViewModel(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher, IEventBus eventBus, IIdFactory idFactory) { _commandDispatcher = commandDispatcher; _eventBus = eventBus; _idFactory = idFactory; AddJourneyCommand = new DelegateCommand(AddJourney); LoadSettingCommand = new DelegateCommand <string>(LoadSetting); SaveSettingCommand = new DelegateCommand <string>(SaveSetting); RemoveSettingCommand = new DelegateCommand <string>(RemoveSetting); DateOfOccurrence = DateTime.Now.Date; Notification = new NotifierViewModel(); Lifts = new ObservableCollection <LiftViewModel>(); try { PassengerNames = queryDispatcher.Dispatch(new GetPeopleNamesQuery()).Select(personName => personName.Name).ToList(); } catch { PassengerNames = new List <string>(); } try { JourneyTemplates = new ObservableCollection <JourneyTemplate>(queryDispatcher.Dispatch(new GetJourneyTemplatesQuery())); } catch { JourneyTemplates = new ObservableCollection <JourneyTemplate>(); } }
public string Manage(TeamFeedModel feedModel) { IEnumerable <int> teamKeys = new List <int>() { feedModel.Key }; EntitiesByKeyQuery <Team> teamQuery = new EntitiesByKeyQuery <Team>(teamKeys); Team team = queryDispatcher.Dispatch <EntitiesByKeyQuery <Team>, IEnumerable <Team> >(teamQuery).FirstOrDefault(); if (team != null) { return(team.Id); } IEnumerable <int> sportKeys = new List <int>() { CommonConstants.ESPORT_KEY }; EntitiesByKeyQuery <Sport> sportQuery = new EntitiesByKeyQuery <Sport>(sportKeys); Sport sport = queryDispatcher.Dispatch <EntitiesByKeyQuery <Sport>, IEnumerable <Sport> >(sportQuery).First(); CreateTeamCommand teamCommand = Mapper.Map <CreateTeamCommand>(feedModel); teamCommand.SportId = sport.Id; return(commandDispatcher.Dispatch <CreateTeamCommand, string>(teamCommand)); }
public void IndexGET_GivenCurrentUser_DisclaimerQueryShouldBeCalled() { A.CallTo(() => _userPrincipalProvider.CurrentUserName).Returns("*****@*****.**"); _controller.Index(); A.CallTo(() => _queryDispatcher.Dispatch <DisclaimerByUserQuery, Disclaimer>(A <DisclaimerByUserQuery> .That.Matches(x => x.AssessorDomainName == _userPrincipalProvider.CurrentUserName))).MustHaveHappened(Repeated.Exactly.Once); }
public QuestionAnswer GetQuestionAnswer(Assessment assessment) { return(_queryDispatcher.Dispatch <QuestionAnswerByAssessmentAndQuestionIdQuery, QuestionAnswer>(new QuestionAnswerByAssessmentAndQuestionIdQuery() { AssessmentId = assessment.AssessmentId, WorkflowQuestionId = assessment.CurrentWorkflowQuestionId })); }
public List <Organization> ListOrganizations(string accessToken) { var query = new ListOrganizations_Q(); var result = _queryDispatcher.Dispatch <ListOrganizations_Q, List <Organization> >(accessToken, query); return(result); }
public void GetRoles_RolesShouldBeReturned() { A.CallTo(() => _queryDispatcher.Dispatch <RoleListQuery, Roles>(A <RoleListQuery> ._)).Returns(new Roles()); var result = _roleHelper.GetRoles(); result.Should().BeOfType <Roles>(); }
public async Task Dispatch_GivenQuery_ReturnsResultOfHandler() { var query = new TestQuery(5); var result = await _dispatcher.Dispatch(query); Assert.Equal(result, "5"); }
public void GetPatient_PatientShouldBeReturned() { A.CallTo(() => _queryDispatcher.Dispatch <PatientByIdQuery, Patient>(A <PatientByIdQuery> ._)).Returns(new Patient()); var result = _patientHelper.GetPatient(A <Guid> ._); result.Should().BeOfType <Patient>(); }
public DscQColumn[] GetColumns(DscQColumnQuery query) { query.UserId = _securityToken?.UserName; query.Password = _securityToken?.Password; DscQColumnQueryResult result = _queryDispatcher.Dispatch <DscQColumnQuery, DscQColumnQueryResult>(query); return(result.Items.ToArray()); }
public virtual ActionResult Create() { var genderQuery = new GenderListQuery(); var result = _queryDispatcher.Dispatch <GenderListQuery, Genders>(genderQuery); var model = _patientViewModelBuilder.BuildPatientViewModel(result); return(View(model)); }
public Assessment GetAssessment(Guid id) { var assessment = _queryDispatcher.Dispatch <AssessmentByIdQuery, Assessment>(new AssessmentByIdQuery { AssessmentId = id }); return(assessment); }
public void GetAssessment_GivenAssessmentId_QueryDispatcherShouldBeCalled() { var assessmentId = Guid.NewGuid(); _assessmentHelper.GetAssessment(assessmentId); A.CallTo(() => _queryDispatcher.Dispatch <AssessmentByIdQuery, Assessment>( A <AssessmentByIdQuery> .That.Matches(x => x.AssessmentId == assessmentId))).MustHaveHappened(Repeated.Exactly.Once); }
public async Task <List <GetUserOrders.Result> > GetOrders() { string email; if ((email = GetEmailFromToken()) != null) { return(await _queryDispatcher.Dispatch <GetUserOrders.Query, List <GetUserOrders.Result> >(new GetUserOrders.Query(email))); } return(null); }
public ActionResult Index(bool?wasRedirected) { HomePageModel model = new HomePageModel(); GetNamesQuery query = new GetNamesQuery(); model.Names = dispatcher.Dispatch <GetNamesQuery, List <Names> >(query); model.NameList = model.Names.Select(item => new SelectListItem { Text = item.Name }); GetAllShoeTypesQuery shoeTypesQuery = new GetAllShoeTypesQuery(); model.ShoeTypes = dispatcher.Dispatch <GetAllShoeTypesQuery, List <ShoeTypes> >(shoeTypesQuery); model.ShoeTypeList = model.ShoeTypes.Select(item => new SelectListItem { Text = item.Description, Value = item.ShoeTypeId.ToString() }); if (wasRedirected.HasValue) { model.isDelete = wasRedirected; } model.isEdit = false; return(View(model)); }
public List <Member> ListMembersForOrganization(string accessToken, int organizationID) { var query = new ListMembersForOrganization_Q { OrganizationID = organizationID }; var result = _queryDispatcher.Dispatch <ListMembersForOrganization_Q, List <Member> >(accessToken, query); return(result); }
public HttpResponseMessage Get() { var query = new AllAirportsQuery { }; var queryResponse = _queryDispatcher.Dispatch <AllAirportsQuery, AllAirportsQueryResult>(query); var okResponse = this.Request.CreateResponse(HttpStatusCode.OK, queryResponse); return(okResponse); }
private void Calculate() { try { TotalCost = _queryDispatcher.Dispatch(new GetCostOfPassengerLiftsInPeriodQuery(Passenger, new Period(From, To))).TotalCost; } catch { TotalCost = 0m; } }
public dynamic GetAbstracts(NetworkRequest request) { var pmidEnumerable = _qry.Dispatch(new AbstractsQuery(request.MirnaEnumerable)); var abstractComponent = _abstractFactory.BuildAbstractComponent(pmidEnumerable); return(new { Abstracts = _abstractFactory.HighlightSearchTerms(request.MirnaEnumerable, abstractComponent, request.TermEnumerable), Count = pmidEnumerable.Count() }); }
public void SetAssessmentWorkflow(AddAssessmentCommand command) { var currentWorkflowVersion = _queryDispatcher.Dispatch <CurrentWorkflowQuery, WorkflowVersion>(new CurrentWorkflowQuery()); command.WorkflowVersionId = currentWorkflowVersion.WorkflowVersionId; command.CurrentWorkflowQuestionId = currentWorkflowVersion.InitialWorkflowQuestionId; _commandDispatcher.Dispatch(command); SaveChanges(); }
public void GetQuestionAnswer_GivenAssessment_QueryDispatcherShouldBeCalled() { var assessment = new Assessment() { AssessmentId = Guid.NewGuid(), CurrentWorkflowQuestionId = Guid.NewGuid() }; _questionAnswerHelper.GetQuestionAnswer(assessment); A.CallTo(() => _queryDispatcher.Dispatch <QuestionAnswerByAssessmentAndQuestionIdQuery, QuestionAnswer>(A <QuestionAnswerByAssessmentAndQuestionIdQuery> .That.Matches(x => x.AssessmentId == assessment.AssessmentId && x.WorkflowQuestionId == assessment.CurrentWorkflowQuestionId))).MustHaveHappened(Repeated.Exactly.Once); }
public void AuthorizeCore_GivenDisclaimerHasBeenAgreed_UserShouldHaveAccess() { A.CallTo(() => _queryDispatcher.Dispatch <DisclaimerByUserQuery, Disclaimer>(A <DisclaimerByUserQuery> ._)) .Returns(new Disclaimer() { IsAgreed = true }); _agreedToDisclaimerAuthorizeAttribute.OnAuthorization(_authorizationContext); var result = _authorizationContext.Result as RedirectToRouteResult; result.Should().BeNull(); }
public IHttpActionResult All(int take) { if (take <= 0) { ModelState.AddModelError("Take", "Invalid request!"); return(BadRequest(ModelState)); } AllMatchesQuery query = new AllMatchesQuery(take); IEnumerable <MatchResult> matches = queryDispatcher.Dispatch <AllMatchesQuery, IEnumerable <MatchResult> >(query); IEnumerable <MatchResponseModel> responseModel = Mapper.Map <IEnumerable <MatchResponseModel> >(matches); return(Ok(responseModel)); }
public Patient GetPatient(Guid id) { return(_queryDispatcher.Dispatch <PatientByIdQuery, Patient>(new PatientByIdQuery { PatientId = id })); }
public override Task <ActionResult <EmployeeDetail> > HandleAsync(Guid employeeId, CancellationToken token) => dispatcher .Dispatch(new EmployeeDetailQuery(employeeId), token) .Match <EmployeeDetail, ActionResult <EmployeeDetail> >( e => e, () => NotFound($"Employee [{employeeId}]"), ex => new APIErrorResult(ex.Message));
public async Task <IActionResult> Handle(RefreshTokenRequest request, CancellationToken cancellationToken) { var userResult = await _queryDispatcher.Dispatch <UserGetByRefreshTokenQuery, Result <ApplicationUser> >(new UserGetByRefreshTokenQuery(request.RefreshToken)); if (userResult.IsFailure) { return(new UnauthorizedResult()); } var user = userResult.Value; var existingRefreshToken = user.RefreshTokens.FirstOrDefault(t => t.Token == request.RefreshToken); if (!existingRefreshToken.IsActive) { return(new UnauthorizedResult()); } var token = _tokenService.GenerateAccessToken(user); var refreshToken = _tokenService.GenerateRefreshToken(user); await _commandDispatcher.Dispatch(new RefreshTokenCreateCommand(refreshToken.ExpiresOn, refreshToken.Token, refreshToken.UserId)); await _commandDispatcher.Dispatch(new RefreshTokenClearExpiredForUserCommand(existingRefreshToken.Token, existingRefreshToken.UserId)); var loginResponse = new LoginResponse { DisplayName = user.DisplayName, RefreshToken = refreshToken.Token, Token = token, UserId = user.Id }; return(new OkObjectResult(loginResponse)); }
public IHttpActionResult Login(LoginRequestModel requestModel) { if (ModelState.IsValid) { AccountCommand accountCommand = Mapper.Map <AccountCommand>(requestModel); IEnumerable <ValidationResult> validations = commandDispatcher.Validate(accountCommand); ModelState.AddModelErrors(validations); if (ModelState.IsValid) { AccountByUsernameQuery query = new AccountByUsernameQuery(requestModel.Username); Account account = queryDispatcher.Dispatch <AccountByUsernameQuery, Account>(query); AuthCommand loginCommand = new AuthCommand(account.Id, requestModel.RememberMe); Authentication authentication = commandDispatcher.Dispatch <AuthCommand, Authentication>(loginCommand); AccountResponseModel responseModel = Mapper .Map <AccountResponseModel>(authentication) .Map(account); return(Ok(responseModel)); } } return(BadRequest(ModelState)); }