public async Task <IViewComponentResult> InvokeAsync() { var lastVideo = (await _contentFileService.GetTopByTypeAsync("video", 1, 10, "", "")).Select(p => new ContentFileViewModel { Id = p.Id, Type = p.Type, Title = p.Title, FileName = p.FileName, ContentId = p.ContentId, ContentText = p.Content.Category.CategoryTags != null ? (string.Join(",", p.Content.Category.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag) .Select(a => a.Title))) : "", Description = p.Description, Ext = p.Ext, FileSize = p.FileSize, LikeCount = p.LikeCount, PhotoFileName = p.Pic, Thumbnail = p.Thumbnail, Pic = p.Pic, VideoFileName = p.FileName, VisitCount = p.VisitCount }).ToList(); return(View(lastVideo)); }
public ActionResult GetAll([FromBody] PageLimitViewModel model) { if (model.Kind == "album") { if (model.OrderBy == "last") { var morLiked = _categoryService.GetTopByType("1", model.PageNumber, model.PageSize, "", true).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, // Artist = p.CategoryTags != null ? (string.Join(",", p.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))) : null, Artist = p.CategoryTags? .Where(t => t.Type == "artist").Select(art => new ArtistViewModel { ArtistId = art.Tag.Id, ArtistName = art.Tag.Title }).ToList(), Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/album/" + p.Pic, Type = "last", Kind = "album", TypeName = "آخرین ها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, Rate = 5, ShareLink = "http://mousigha.com/album/detail/" + p.Id }); return(Ok(morLiked)); } if (model.OrderBy == "like") { var lk = _categoryService.GetTopByLike("1", model.PageNumber, model.PageSize, true).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, //Artist = (string.Join(",", p.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))), // Artist = p.CategoryTags != null ? (string.Join(",", p.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))) : null, Artist = p.CategoryTags? .Where(t => t.Type == "artist").Select(art => new ArtistViewModel { ArtistId = art.Tag.Id, ArtistName = art.Tag.Title }).ToList(), Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/album/" + p.Pic, Type = "like", Kind = "album", TypeName = "محبوب ترین ها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, Rate = 5, ShareLink = "http://mousigha.com/album/detail/" + p.Id }); return(Ok(lk)); } } if (model.Kind == "video") { var moreLike = new List <AppHomeViewModel>(); if (model.PageNumber == 1) { moreLike = (_contentFileService.GetTopByTypeAsync("video", 1, 6, "", "like").Result).ToList() .Select(p => new AppHomeViewModel { Id = p.Id, Title = p.Title, VideoArtist = p.Content.Category.CategoryTags != null ? (string.Join(",", p.Content.Category.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag) .Select(a => a.Title))) : "", Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Pic = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Video = "http://mousigha.com/content/files/album/" + p.FileName, Type = "last", Kind = "video", TypeName = "آخرین ویدئوها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, ShareLink = "http://mousigha.com/video/detail/" + p.Id }).ToList(); } var videos = (_contentFileService.GetTopByTypeAsync("video", model.PageNumber, model.PageSize, "", "").Result).ToList() .Select(p => new AppHomeViewModel { Id = p.Id, Title = p.Title, VideoArtist = p.Content.Category.CategoryTags != null ? (string.Join(",", p.Content.Category.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))) : "", Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Pic = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Video = "http://mousigha.com/content/files/album/" + p.FileName, Type = "last", Kind = "video", TypeName = "آخرین ویدئوها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, ShareLink = "http://mousigha.com/video/detail/" + p.Id }); return(Ok(new { videos, moreLike })); } if (model.Kind == "tag") { // if (model.OrderBy == "last") { var tag = _tagService.GetPagedTagsAsync(1, 10, SortOrder.Descending, "tag", null, "last", true, null).Result.Tags.ToList(); var tags = tag.Select(p => new AppHomeViewModel { Id = p.Id, Title = "#" + p.Title.Replace(" ", "_"), Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, Type = "last", Kind = "tag", TypeName = "تگ ها", LikeCount = p.LikeCount, ShareLink = "http://mousigha.com/tag/detail/" + p.Id }); return(Ok(tags)); } } if (model.Kind == "style") { // if (model.OrderBy == "last") { var tag = _tagService.GetPagedTagsAsync(model.PageNumber, model.PageSize, SortOrder.Descending, model.Kind, null, "", true, null).Result.Tags.ToList(); var tags = tag.Select(p => new AppHomeViewModel { Id = p.Id, Title = p.Title, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, Type = "last", Kind = "style", TypeName = "سبک ها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, ShareLink = "http://mousigha.com/style/detail/" + p.Id }); return(Ok(tags)); } } if (model.Kind == "music") { // if (model.OrderBy == "last") { var tag = _tagService.GetPagedTagsAsync(model.PageNumber, model.PageSize, SortOrder.Descending, "music", null, "last", true, null).Result.Tags.ToList(); var tags = tag.Select(p => new AppHomeViewModel { Id = p.Id, Title = p.Title, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, Type = "last", Kind = "music", TypeName = "ساز ها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, ShareLink = "http://mousigha.com/music/detail/" + p.Id }); return(Ok(tags)); } } if (model.Kind == "artist") { if (model.OrderBy == "last") { var tag = _tagService.GetPagedTagsAsync(model.PageNumber, model.PageSize, SortOrder.Descending, model.Kind, null, "last", true, null).Result.Tags.ToList(); var tags = tag.Select(p => new AppHomeViewModel { Id = p.Id, Title = p.Title, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, Type = "last", Kind = "artist", TypeName = "هنرمندان", LikeCount = p.LikeCount, VisitCount = p.VisitCount, Rate = 0, ShareLink = "http://mousigha.com/artist/detail/" + p.Id }); return(Ok(tags)); } } if (model.Kind == "all") { var latest = _categoryService.GetTopByType("1", model.PageNumber, model.PageSize, "", true).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, // Artist = p.CategoryTags != null ? (string.Join(",", p.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))) : null, Artist = p.CategoryTags? .Where(t => t.Type == "artist").Select(art => new ArtistViewModel { ArtistId = art.Tag.Id, ArtistName = art.Tag.Title }).ToList(), Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/album/" + p.Pic, Type = "album-last", Kind = "album", OrderBy = "last", TypeName = "آخرین ها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, Rate = 5, ShareLink = "http://mousigha.com/album/detail/" + p.Id }); var morLiked = _categoryService.GetTopByLike("1", model.PageNumber, model.PageSize, true).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, // Artist = p.CategoryTags != null ? (string.Join(",", p.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))) : null, Artist = p.CategoryTags? .Where(t => t.Type == "artist").Select(art => new ArtistViewModel { ArtistId = art.Tag.Id, ArtistName = art.Tag.Title }).ToList(), Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/album/" + p.Pic, Type = "album-like", Kind = "album", OrderBy = "like", TypeName = "محبوب ترین ها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, Rate = 5, ShareLink = "http://mousigha.com/album/detail/" + p.Id }); var style = _tagService.GetPagedTagsAsync(1, 10, SortOrder.Descending, "style", null, "", true, null).Result.Tags.ToList(); var styles = style.Select(p => new AppHomeViewModel { Id = p.Id, Title = p.Title, // Artist = (string.Join(",", p.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))), Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, Video = null, Type = "style-last", Kind = "style", OrderBy = "last", TypeName = "سبک ها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, Rate = 0, ShareLink = "http://mousigha.com/style/detail/" + p.Id }); var tag = _tagService.GetPagedTagsAsync(1, 10, SortOrder.Descending, "tag", null, "", true, null).Result.Tags.ToList(); var tags = tag.Select(p => new AppHomeViewModel { Id = p.Id, Title = "#" + p.Title.Replace(" ", "_"), Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, Type = "tag-last", Kind = "tag", OrderBy = "last", TypeName = "تگ ها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, Rate = 0, ShareLink = "http://mousigha.com/tag/detail/" + p.Id }); var videos = (_contentFileService.GetTopByTypeAsync("video", model.PageNumber, model.PageSize, "", "").Result).ToList() .Select(p => new AppHomeViewModel { Id = p.Id, Title = p.Title, VideoArtist = p.Content.Category.CategoryTags != null ? (string.Join(",", p.Content.Category.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))) : null, //VideoArtist = p.CategoryTags? // .Where(t => t.Type == "artist").Select(art => new ArtistViewModel // { // ArtistId = art.Tag.Id, // ArtistName = art.Tag.Title // }).ToList(), Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Pic = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Video = string.IsNullOrEmpty(p.FileName) ? "" : "http://mousigha.com/content/files/album/" + p.FileName, Type = "video-last", Kind = "video", OrderBy = "last", TypeName = "آخرین ویدئوها", LikeCount = p.LikeCount, VisitCount = p.VisitCount, Rate = 0, ShareLink = "https://www.mousigha.com/album/detail/" + p.Id }); var sliders = (_sliderService.GetAll(1, "enable", model.PageNumber, model.PageSize)).ToList() .Select(p => new AppHomeViewModel { Title = p.Title, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "https://www.mousigha.com/content/files/slider/" + p.Pic, Video = "", //Type = p.Link.StartsWith("https://www.mousigha.com/album")==true?"album":"100", Kind = "slider", OrderBy = "last", TypeName = "اسلایدر", Type = SetType(p.Link), Link = p.Link, Rate = 0, SubTitle = p.SubTitle, Id = SetType(p.Link) == "album" ? Convert.ToInt32(Regex.Match(p.Link, @"\d+$").Value) : p.Id }); var merged = sliders.Union(styles).ToList(); merged = merged.Union(latest.ToList()).ToList(); merged = merged.Union(tags.ToList()).ToList(); merged = merged.Union(morLiked.ToList()).ToList(); merged = merged.Union(videos.ToList()).ToList(); //merged = merged.Union(sliders.ToList()).ToList(); //var merged = morLiked.Union(latest).ToList(); //merged = merged.Union(styles.ToList()).ToList(); //merged = merged.Union(videos.ToList()).ToList(); //merged = merged.Union(tags.ToList()).ToList(); //merged = merged.Union(sliders.ToList()).ToList(); return(Ok(merged)); } return(Ok()); }
public ActionResult GetAll([FromBody] PageLimitViewModel model) { if (string.IsNullOrEmpty(model.Term)) { return(Ok()); } if (model.Kind == "album") { var albums = _categoryService.GetForSearch("1", model.PageNumber, model.PageSize, model.Term, true).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, // Artist = p.CategoryTags != null ? (string.Join(",", p.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))) : null, Artist = p.CategoryTags? .Where(t => t.Type == "artist").Select(art => new ArtistViewModel { ArtistId = art.Tag.Id, ArtistName = art.Tag.Title }).ToList(), Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Kind = "album", ShareLink = "http://mousigha.com/album/detail/" + p.Id, VisitCount = p.VisitCount, LikeCount = p.LikeCount, TypeName = "آلبوم ها", }); return(Ok(albums)); } if (model.Kind == "artist") { var artist = _tagService.GetPagedTags(model.PageNumber, model.PageSize, "artist", model.Term).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, VisitCount = p.VisitCount, LikeCount = p.LikeCount, Kind = "artist", TypeName = "هنرمندان", ShareLink = "http://mousigha.com/artist/detail/" + p.Id, SubTitle = p.Content != null ? Regex.Replace(p.Content, "<.*?>", string.Empty).Length > 200 ? Regex.Replace(p.Content, "<.*?>", string.Empty).Substring(0, 200).Replace(" ", " ").Replace("&zwnj", " ").Replace("&zwj", " ") : Regex.Replace(p.Content, "<.*?>", string.Empty) : "" }); return(Ok(artist)); } if (model.Kind == "style") { var style = _tagService.GetPagedTags(model.PageNumber, model.PageSize, "style", model.Term).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, VisitCount = p.VisitCount, LikeCount = p.LikeCount, Kind = "style", ShareLink = "http://mousigha.com/style/detail/" + p.Id, TypeName = "سبک ها", SubTitle = Regex.Replace(p.Content, "<.*?>", string.Empty).Length > 200 ? Regex.Replace(p.Content, "<.*?>", string.Empty).Substring(0, 200).Replace(" ", " ").Replace("&zwnj", " ").Replace("&zwj", " ") : Regex.Replace(p.Content, "<.*?>", string.Empty) }); return(Ok(style.ToList())); } if (model.Kind == "music") { var music = _tagService.GetPagedTags(model.PageNumber, model.PageSize, "music", model.Term).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, VisitCount = p.VisitCount, LikeCount = p.LikeCount, Kind = "music", ShareLink = "http://mousigha.com/music/detail/" + p.Id, TypeName = "سازها", SubTitle = Regex.Replace(p.Content, "<.*?>", string.Empty).Length > 200 ? Regex.Replace(p.Content, "<.*?>", string.Empty).Substring(0, 200).Replace(" ", " ").Replace("&zwnj", " ").Replace("&zwj", " ") : Regex.Replace(p.Content, "<.*?>", string.Empty) }); return(Ok(music.ToList())); } if (model.Kind == "video") { var artist = _contentFileService.GetTopByTypeAsync("video", model.PageNumber, model.PageSize, model.Term, "").Result.Select( p => new AppHomeViewModel { VisitCount = p.VisitCount, LikeCount = p.LikeCount, Id = p.Id, Title = p.Title, Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Video = string.IsNullOrEmpty(p.FileName) ? "" : "http://mousigha.com/content/files/album/" + p.FileName, Kind = "video", ShareLink = "http://mousigha.com/video/detail/" + p.Id, TypeName = "موزیک ویدیو" }); return(Ok(artist)); } else { var albums = _categoryService.GetForSearch("1", model.PageNumber, model.PageSize, model.Term, true).Select( p => new AppHomeViewModel { VisitCount = p.VisitCount, LikeCount = p.LikeCount, Id = p.Id, Title = p.Title, // Artist = p.CategoryTags != null ? (string.Join(",", p.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))) : null, Artist = p.CategoryTags? .Where(t => t.Type == "artist").Select(art => new ArtistViewModel { ArtistId = art.Tag.Id, ArtistName = art.Tag.Title }).ToList(), ShareLink = "http://mousigha.com/album/detail/" + p.Id, Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Type = "last", Kind = "album", TypeName = "آلبوم ها", }); var artist = _tagService.GetPagedTags(model.PageNumber, model.PageSize, "artist", model.Term).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, VisitCount = p.VisitCount, LikeCount = p.LikeCount, Kind = "artist", ShareLink = "http://mousigha.com/artist/detail/" + p.Id, TypeName = "هنرمندان", SubTitle = p.Content != null ? Regex.Replace(p.Content, "<.*?>", string.Empty).Length > 200 ? Regex.Replace(p.Content, "<.*?>", string.Empty).Substring(0, 200).Replace(" ", " ").Replace("&zwnj", " ").Replace("&zwj", " ") : Regex.Replace(p.Content, "<.*?>", string.Empty) : "" }); var style = _tagService.GetPagedTags(model.PageNumber, model.PageSize, "style", model.Term).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, VisitCount = p.VisitCount, LikeCount = p.LikeCount, Kind = "style", ShareLink = "http://mousigha.com/style/detail/" + p.Id, TypeName = "سبک ها", }); var music = _tagService.GetPagedTags(model.PageNumber, model.PageSize, "music", model.Term).Select( p => new AppHomeViewModel { Id = p.Id, Title = p.Title, Pic = string.IsNullOrEmpty(p.Pic) ? "" : "http://mousigha.com/content/files/tag/" + p.Pic, Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/tag/" + p.Thumbnail, VisitCount = p.VisitCount, LikeCount = p.LikeCount, Kind = "music", ShareLink = "http://mousigha.com/music/detail/" + p.Id, TypeName = "ساز ها", }); style = style.Union(music); var video = _contentFileService.GetTopByTypeAsync("video", model.PageNumber, model.PageSize, model.Term, "").Result.Select( p => new AppHomeViewModel { VisitCount = p.VisitCount, LikeCount = p.LikeCount, Id = p.Id, Title = p.Title, Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail, Video = string.IsNullOrEmpty(p.FileName) ? "" : "http://mousigha.com/content/files/album/" + p.FileName, Kind = "video", ShareLink = "http://mousigha.com/video/detail/" + p.Id, TypeName = "موزیک ویدیو" }); var merged = albums.Union(artist).ToList(); merged = merged.Union(style.ToList()).ToList(); merged = merged.Union(video.ToList()).ToList(); return(Ok(merged)); } }