public async Task <IActionResult> Index(Guid id) { var questionResponse = await _queries.Request <GetQuestionRequest, GetQuestionResponse>(new GetQuestionRequest { Id = id }); var question = questionResponse.Question; if (question == null) { return(NotFound()); } var profileResponse = await _queries.Request <GetProfileRequest, GetProfileResponse>(new GetProfileRequest { Id = question.CreatedById }); var profile = profileResponse.Profile; var page = new QuestionPageViewModel { Question = new QuestionViewModel { Id = question.Id, Title = question.Title }, UserAsking = new UserViewModel { Id = profile.Id, Name = profile.Name, TotalGoldBadges = profile.Badges.Count(x => x.Badge.Rank == BadgeRank.Gold), TotalSilverBadges = profile.Badges.Count(x => x.Badge.Rank == BadgeRank.Silver), TotalBronzeBadges = profile.Badges.Count(x => x.Badge.Rank == BadgeRank.Bronze) } }; return(View(page)); }
public async Task <IActionResult> ForPodcastCreation(Guid id) { var result = await _queries.Request <GetPodcastQuery, GetPodcastQueryResult>(new GetPodcastQuery { Id = id }); if (result.Podcast == null) { return(View(new WaitModel { Id = id })); } return(RedirectToAction("Index", "Podcast", new { id })); }
public async Task <IActionResult> Index(Guid id) { var categoryResult = await _queries.Request <GetCategoryQuery, GetCategoryQueryResult>(new GetCategoryQuery { Id = id }); var podcastsResult = await _queries.Request <GetPodcastsQuery, GetPodcastsQueryResult>(new GetPodcastsQuery { CategoryId = id }); var model = new CategoryPageModel { Category = Mapper.Map <Category, CategoryViewModel>(categoryResult.Category), Podcasts = Mapper.Map <IEnumerable <Podcast>, IEnumerable <PodcastViewModel> >(podcastsResult.Podcasts) }; return(View(model)); }
public async Task <IActionResult> Index(Guid id) { var podcastResult = await _queries.Request <GetPodcastQuery, GetPodcastQueryResult>(new GetPodcastQuery { Id = id }); var categoryResult = await _queries.Request <GetCategoryQuery, GetCategoryQueryResult>(new GetCategoryQuery { Id = podcastResult.Podcast.Id }); var model = new PodcastPageModel { Category = Mapper.Map <Category, CategoryViewModel>(categoryResult.Category), Podcast = Mapper.Map <Podcast, PodcastViewModel>(podcastResult.Podcast) }; return(View(model)); }
public async Task <IActionResult> Index(Guid id) { var result = await _queries.Request <GetPodcastQuery, GetPodcastQueryResult>(new GetPodcastQuery { Id = id }); var model = Mapper.Map <Podcast, PodcastViewModel>(result.Podcast); return(View(model)); }
public async Task <IActionResult> Get(int?userId, [FromQuery] DateTime?startDate, [FromQuery] DateTime?endDate) { //Assume time part is not important. var query = new GetAuditEventQuery { UserId = userId, StartDate = startDate, EndDate = endDate }; var result = await _queryDispatcher.Request <GetAuditEventQuery, GetAuditEventQueryResult>(query); return(Ok(result)); }
public async Task <IActionResult> Index() { var result = await _queries.Request <GetCategoriesQuery, GetCategoriesQueryResult>(new GetCategoriesQuery()); var model = new DashboardPageModel { Categories = Mapper.Map <IEnumerable <Category>, IEnumerable <CategoryViewModel> >(result.Categories) }; return(View(model)); }
public async Task <UserViewModel> Get(Guid id) { var identityResponse = _queries.Request <GetIdentityRequest, GetIdentityResponse>(new GetIdentityRequest { Id = id }); var profileResponse = _queries.Request <GetProfileRequest, GetProfileResponse>(new GetProfileRequest { Id = id }); await Task.WhenAll(identityResponse, profileResponse); var identity = identityResponse.Result.Identity; var profile = profileResponse.Result.Profile; return(new UserViewModel { Id = id, Name = identity.FirstName + " " + identity.LastName, UserName = identity.UserName, TotalBronzeBadges = profile.Badges.Count(x => x.Badge.Rank == BadgeRank.Bronze), TotalSilverBadges = profile.Badges.Count(x => x.Badge.Rank == BadgeRank.Silver), TotalGoldBadges = profile.Badges.Count(x => x.Badge.Rank == BadgeRank.Gold) }); }
public async Task <IActionResult> Get(Guid id) { var response = await _queries.Request <GetProfileRequest, GetProfileResponse>(new GetProfileRequest { Id = id }); if (response.Profile == null) { return(NotFound()); } var model = new UserModel { Id = response.Profile.Id, Name = response.Profile.Name }; return(Json(model)); }
public async Task Handle(PodcastCreatedEvent evnt) { var id = evnt.Id; var result = await _queryDispatcher.Request <GetPodcastQuery, GetPodcastQueryResult>(new GetPodcastQuery { Id = id }); var podcast = result.Podcast; var podcastDocument = new PodcastDocument { Id = podcast.Id.ToString(), Title = podcast.Title, Category = podcast.CategoryName, Tags = podcast.Tags }; await _indexer.Update(podcastDocument); }
public async Task <IActionResult> Index() { var result = await _queries.Request <SearchQuery, SearchQueryResult>(new SearchQuery { Query = "car" }); return(View()); }