public IActionResult View([FromServices] BlogQueryFactory blogQueryFactory, BlogFromIdQuery query) { var blog = blogQueryFactory.Build(query).Get(); var viewModel = _mapper.Map <BlogViewModel>(blog); viewModel.IsOwner = blog.OwnerId == _userManager.GetUserId(User); return(View(viewModel)); }
public async Task <IActionResult> Index([FromServices] BlogQueryFactory blogFactory) { var query = new AllBlogsQueryAsync(); var blogs = await blogFactory.Build(query).Get().ToList(); var viewModel = _mapper.Map <BlogIndexViewModel>(blogs); return(View(viewModel)); }