public ActionResult PublicationList(int?page) { IPublicationService pubService = new PublicationService(); var pubList = pubService.GetAllPublicationsList(); List <PublicationAdminListViewModel> pubVMList = new List <PublicationAdminListViewModel>(); foreach (var item in pubList) { string categoryName; if (item.Category == null) { categoryName = ""; } else { categoryName = item.Category.Name; } string pubDate; if (item.ShareDate == null) { pubDate = ""; } else { pubDate = item.ShareDate.ToString(); } pubVMList.Add(new PublicationAdminListViewModel() { Id = item.PublicationId, Title = item.Title, Description = item.Description, Category = categoryName, AuthorName = item.Author.Name + " " + item.Author.Surname, ShareDate = pubDate, isShared = item.IsShared, }); } int pageSize = 40; int pageNumber = (page ?? 1); return(View(pubVMList.ToPagedList(pageNumber, pageSize))); }