public ViewResult Index() { var model = _videos.GetAll().Select(video => new VideoViewModel { Id = video.Id, Title = video.Title, Genre = video.Genre.ToString() }); return(View(model)); }
public IActionResult Index() { IndexViewModel pageModel = new IndexViewModel(); pageModel.Videos = _videoService.GetAll() .Where(v => v.State.StateName == "Active") .OrderByDescending(v => v.CreatedDate) .Take(12) .ToList().Select(v => new VideoViewModel { Id = v.Id, Title = v.Title, VideoUrl = v.VideoUrl, ThumbnailUrl = v.ThumbnailUrl, GroupName = v.GroupName, Description = v.Description, ViewCount = v.ViewCount, Duration = v.Duration.TotalHours >= 1 ? v.Duration.ToString("hh\\:mm\\:ss") : v.Duration.Minutes >= 1 ? v.Duration.ToString($"mm\\:ss") : v.Duration.ToString("ss"), CreateUser = new UserViewModel { UserName = v.CreateUser.UserName, FirstName = v.CreateUser.FirstName, LastName = v.CreateUser.LastName, AvatarUrl = v.CreateUser.AvatarUrl }, CreatedDate = v.CreatedDate, UpdateUser = new UserViewModel { UserName = v.UpdateUser.UserName, FirstName = v.UpdateUser.FirstName, LastName = v.UpdateUser.LastName, AvatarUrl = v.UpdateUser.AvatarUrl }, UpdatedDate = v.UpdatedDate }).ToArray(); Bundle <IndexViewModel> model = new Bundle <IndexViewModel>(); model.PageModel = pageModel; ViewData["Title"] = "Home Page"; 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 IEnumerable <Video> GetAll() { return(_videoRepository.GetAll()); }