public ActionResult Edit(string type, int id)
        {
            var c = _contentFileService.FindByIdAsync(id).Result;
            var m = new ContentFileViewModel
            {
                Title       = c.Title,
                Type        = c.Type,
                Thumbnail   = c.Thumbnail,
                Pic         = c.Pic,
                Id          = c.Id,
                Description = c.Description,
                ContentText = c.ContentText != null?
                              c.ContentText.Replace("../../content/files/editor/", "/content/files/editor/")
                              .Replace("../content/files/editor/", "/content/files/editor/")
                              .Replace("..//content/files/editor/", "/content/files/editor/") : "",
                                  ContentId      = c.ContentId,
                                  Ext            = c.Ext,
                                  FileName       = c.FileName,
                                  FileName2      = c.FileName2,
                                  FileName3      = c.FileName3,
                                  LikeCount      = c.LikeCount,
                                  PhotoFileName  = c.Pic,
                                  VideoFileName  = c.FileName,
                                  VideoFileName2 = c.FileName2,
                                  VideoFileName3 = c.FileName3,

                                  VisitCount = c.VisitCount,
                                  IsSelected = Convert.ToBoolean(c.IsSelected),
                                  IsPublic   = Convert.ToBoolean(c.IsPublish)
            };

            ViewBag.ContentName = c.Content.Title;
            return(View(m));
        }
Exemple #2
0
        public ActionResult GetItemList([FromBody] PageLimitViewModel model)
        {
            if (model.Kind == "album")
            {
                var p = _categoryService.FindByIdAsync(model.Id, model.FirstVisit).Result;

                var album = new
                {
                    p.Id,
                    p.Title,

                    Artist = p.CategoryTags != null ? (string.Join(",", p.CategoryTags.Where(t => t.Type == "artist").Select(x => x.Tag).Select(a => a.Title))) : null,
                    p.ContentText,
                    p.Description,
                    p.VisitCount,
                    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,
                    p.LikeCount,

                    ShareLink = "http://mousigha.com/album/detail/" + p.Id,


                    Musics = p.Contents.Select(a => new
                    {
                        a.Id,
                        Mp3128 = string.IsNullOrEmpty(a.Mp3128) ? "" : "http://mousigha.com/content/files/album/" + a.Mp3128,
                        Mp364  = string.IsNullOrEmpty(a.Mp364) ? "" : "http://mousigha.com/content/files/album/" + a.Mp364,
                        Mp3320 = string.IsNullOrEmpty(a.Mp3320) ? "" : "http://mousigha.com/content/files/album/" + a.Mp3320,

                        a.ContentText,
                        Title = Regex.Replace(a.Title, @"^[\d-]*\s*", "", RegexOptions.Multiline),

                        Thumbnail = string.IsNullOrEmpty(p.Thumbnail) ? "" : "http://mousigha.com/content/files/album/" + p.Thumbnail,
                        ShareLink = "http://mousigha.com/content/files/album/" + a.Mp364,

                        //   a.Thumbnail,
                        a.VisitCount,
                        a.LikeCount
                    })
                };
                return(Ok(album));
            }

            if (model.Kind == "video")
            {
                var p = _contentFileService.FindByIdAsync(model.Id, model.FirstVisit).Result;

                var video = new
                {
                    p.Id,
                    p.Title,
                    ArtistId = p.Content?.Category?.CategoryTags?.FirstOrDefault(t => t.Type == "artist")?.TagId,
                    Artist   = 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,
                    p.ContentText,
                    Description = p.ContentText,
                    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,
                    p.LikeCount,
                    Video = string.IsNullOrEmpty(p.FileName) ? "" : "http://mousigha.com/content/files/album/" + p.FileName,
                    p.VisitCount,
                    ShareLink = "http://mousigha.com/video/detail/" + p.Id
                };

                return(Ok(video));
            }

            if (model.Kind == "tag" || model.Kind == "style" || model.Kind == "music")
            {
                var tags = _categoryService.GetTopByTypeAsync("1", model.PageNumber, model.PageSize, model.Id, true).Result.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,
                    ShareLink  = "http://mousigha.com/style/detail/" + p.Id
                });
                return(Ok(tags));
            }
            return(Ok());
        }
        public ActionResult GetById([FromBody] PageLimitViewModel model)
        {
            var video    = _contentFileService.FindByIdAsync(model.Id, model.FirstVisit).Result;
            var artistId = video.Content?.Category?.CategoryTags?.FirstOrDefault(t => t.Type == "artist")?.TagId;

            var rel = _contentFileService.GetByTagIdAsync((int)artistId).Result.Where(p => p.Id != model.Id);

            var result = new
            {
                video = new
                {
                    video.Id,
                    Video     = "http://mousigha.com/content/files/album/" + video.FileName,
                    Pic       = "http://mousigha.com/content/files/album/" + video.Thumbnail,
                    Thumbnail = "http://mousigha.com/content/files/album/" + video.Thumbnail,
                    ArtistId  = video.Content?.Category?.CategoryTags?.FirstOrDefault(t => t.Type == "artist")?.TagId,

                    video.Title,
                    video.VisitCount,
                    video.LikeCount,
                    Description = video.ContentText,


                    Artist = video.Content.Category.CategoryTags != null ?
                             (string.Join(",", video.Content.Category.CategoryTags.Where(t => t.Type == "artist")
                                          .Select(x => x.Tag).Select(a => a.Title))) : null,
                    ShareLink = "http://mousigha.com/video/detail/" + video.Id,

                    Related = rel.Select(
                        p => new
                    {
                        p.Id,
                        Video     = "http://mousigha.com/content/files/album/" + p.FileName,
                        Pic       = "http://mousigha.com/content/files/album/" + p.Thumbnail,
                        Thumbnail = "http://mousigha.com/content/files/album/" + p.Thumbnail,
                        p.Title,
                        p.VisitCount,
                        p.LikeCount,
                        p.Description,
                        //
                    })
                },
                ArtistVideo = rel.Select(
                    p => new
                {
                    p.Id,
                    Video     = "http://mousigha.com/content/files/album/" + p.FileName,
                    Pic       = "http://mousigha.com/content/files/album/" + p.Thumbnail,
                    Thumbnail = "http://mousigha.com/content/files/album/" + p.Thumbnail,

                    p.Title,
                    p.VisitCount,
                    p.LikeCount,
                    p.Description,
                    //  ShareLink = "http://mousigha.com/share"
                }
                    )
            };

            return(Ok(result));
        }