public HttpResponseMessage GetPagedList(GetPagedListDTO dto) { var pageIndex = dto.offset / dto.limit; string sStatus = (string.IsNullOrWhiteSpace(dto.status) ? null : dto.status); IPagedList <Article> arts = _repository.GetPagedList(ActiveModule.ModuleID, pageIndex, dto.limit, dto.searchPhrase, null, true, -1, null, null, null, dto.sortBy, dto.sortAsc); var artsVM = Mapper.Map <List <Article>, List <ArticleViewModel> >(arts.ToList()); var artPerms = new ArticlePermissions(UserInfo, ActiveModule, PortalSettings); artsVM.ForEach(a => { setVwUrl(ref a); a.Actions = artPerms.GetArticleActions(Mapper.Map <ArticleViewModel, Article>(a)); }); return(Request.CreateResponse(new { data = artsVM, meta = new PagedListMetaViewModel(arts) })); }
public HttpResponseMessage Get(GetDTO dto) { ArticleViewModel art; if (dto.articleId <= 0) { art = new ArticleViewModel(); art.Actions.Add("Edit"); art.ArticleID = -1; art.ModuleID = ActiveModule.ModuleID; art.AuthorID = UserInfo.UserID; art.StartDate = DateTime.Now; } else { art = Mapper.Map <Article, ArticleViewModel>(_repository.Get(dto.articleId, ActiveModule.ModuleID)); var artPerms = new ArticlePermissions(UserInfo, ActiveModule, PortalSettings); setVwUrl(ref art); art.Actions = artPerms.GetArticleActions(Mapper.Map <ArticleViewModel, Article>(art)); } return(Request.CreateResponse(art)); }