public ActionResult Index(VideoIndexModel model, int?page) { int defautPagesize = 10; int total = 0; int currentPageIndex = page.HasValue ? page.Value - 1 : 0; IVideosService videoSrv = IoC.Resolve <IVideosService>(); IVideoTypeService videotypeSrv = IoC.Resolve <IVideoTypeService>(); model.VideoTypes = videotypeSrv.Query.OrderBy(p => p.NameVNI).OrderBy(p => p.NameENG).ToList(); string kw = String.IsNullOrWhiteSpace(model.Keyword) ? null : model.Keyword.Trim(); IList <Videos> list = new List <Videos>(); string username = HttpContext.User.Identity.Name; model.TypeID = string.IsNullOrWhiteSpace(model.TypeID) ? "0" : model.TypeID; int cID = 0; int.TryParse(model.TypeID, out cID); if (HttpContext.User.IsInRole("Root")) { list = videoSrv.GetBySearch(kw, cID, currentPageIndex, defautPagesize, out total); } else { list = videoSrv.GetBySearch(kw, cID, username, currentPageIndex, defautPagesize, out total); } model.Videos = new PagedList <Videos>(list, currentPageIndex, defautPagesize, total); return(View(model)); }
public IActionResult ListVideo() { var assetModels = _videos.GetAll(); var ListingResult = assetModels .Select(result => new VideoIndexListingModel { Id = result.Id, ImageURL = result.ImageUrl, AuthorOrDirector = _videos.GetAuthorOrDirector(result.Id), Title = result.Title, NumberOfCopies = result.NumberOfCopies.ToString(), Year = result.Year.ToString(), Status = result.Status.ToString(), Cost = result.Cost.ToString(), Location = _asset.GetCurrentLocation(result.Id)?.Name.ToString() }); var model = new VideoIndexModel() { Videos = ListingResult }; return(View(model)); // return Content(mess); }
public IActionResult Index() { VideoIndexModel vim = new VideoIndexModel(); using (var connObject = new SqlConnection(configuration.GetConnectionString("MsSQL"))) { string showcaseQuery = @" SELECT TOP 3 v.ID as VideoID, v.ThumbnailUrl as VideoThumbnail, v.Name as VideoName, v.Description as VideoDescription, v.IsLive, s.Name as VideoShow, c.Name as VideoCommunity, s.ID as VideoShowID, c.ID as VideoCommunityID FROM VideoTable as v JOIN ShowTable as s ON v.ShowID=s.ID JOIN CommunityTable as c ON s.CommunityID=c.ID WHERE v.IsLive=0 and v.IsScheduled=0 ORDER BY v.Date DESC"; string dropdownCommunitiesQuery = @"SELECT c.ID as CommunityID, c.Name as CommunityName FROM CommunityTable c"; string dropdownShowsQueryPrefix = "SELECT TOP 6 ID as ShowID, Name as ShowName,ImageUrl as ShowImageUrl FROM ShowTable WHERE CommunityID="; connObject.Open(); vim.ShowcaseVideos = connObject.Query <ShowcaseVideo>(showcaseQuery); IEnumerable <DropdownCommunity> communities = connObject.Query <DropdownCommunity>(dropdownCommunitiesQuery); foreach (var c in communities) { c.Shows = connObject.Query <CommunityShows>(dropdownShowsQueryPrefix + c.CommunityID); } vim.DropdownCommunities = communities; string baseLiveQuery = @"SELECT TOP 1 v.ID, v.Name, v.Description as Description, l.Url4 as VideoUrl, s.Name as ShowName, c.Name as CommunityName, s.ID as ShowID, c.ID as CommunityID, s.ImageUrl as ShowImageUrl FROM VideoTable as v JOIN ShowTable as s ON v.ShowID=s.ID JOIN LinkTable l ON v.LinkID=l.ID JOIN CommunityTable as c ON s.CommunityID=c.ID"; string liveVideoQuery = baseLiveQuery + " WHERE IsLive=1"; vim.LiveVideo = connObject.Query <LiveVideo>(liveVideoQuery).FirstOrDefault(); string upcomingLiveVideoQuery = baseLiveQuery + " WHERE IsScheduled=1"; vim.UpcomingLiveVideo = connObject.Query <LiveVideo>(upcomingLiveVideoQuery).FirstOrDefault(); connObject.Close(); } return(View(vim)); }