public async Task <ActionResult <ICollection <FeedViewModel> > > GetFeedCollectionAsync(CancellationToken cancellationToken, string userName = null) { var result = await _feedService.GetAsync(cancellationToken, userName); return(Ok(result)); }
public async Task <FeedPageListModel> GetUserFeedsAsync(ClaimsPrincipal claimsPrincipal, FeedFilterModel criterias) { if (criterias == null) { criterias = new FeedFilterModel(); } if (string.IsNullOrEmpty(criterias.UserIdentityId)) { return(new FeedPageListModel(new List <FeedModel>()) { Filter = criterias }); } var currentUserId = GetCurrentUserId(claimsPrincipal); var userId = await _userManager.DecryptUserIdAsync(criterias.UserIdentityId); var filterRequest = new FeedFilter { Page = criterias.Page, PageSize = _pagerOptions.PageSize, Keyword = criterias.Search, CreatedById = userId, CanGetInactived = currentUserId == userId }; try { var feedPageList = await _feedService.GetAsync(filterRequest); var feeds = await _feedModelService.MapFeedsResultToModelAsync(feedPageList.Collections); var feedPage = new FeedPageListModel(feeds) { Filter = criterias, TotalPage = feedPageList.TotalPage, TotalResult = feedPageList.TotalResult }; return(feedPage); } catch (Exception) { throw; } }
public async Task <IActionResult> Get(int id, int feedCollectionId, int userId) { var feedDto = await _feedService.GetAsync(id, feedCollectionId, userId); return(_feedResponseCreator.ResponseForGet(feedDto)); }