Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(ContentFileViewModel model, int id)
        {
            var content = await _contentFileService.FindByIdAsync(id).ConfigureAwait(false);

            content.Title       = model.Title.Trim();
            content.Thumbnail   = model.Thumbnail;
            content.ContentText = model.ContentText != null?model.ContentText
                                  .Replace("../../content/files/editor/", "/content/files/editor/")
                                  .Replace("../content/files/editor/", "/content/files/editor/")
                                  .Replace("..//content/files/editor/", "/content/files/editor/") : "";

            content.Pic         = model.Pic;
            content.FileName    = model.FileName;
            content.FileName2   = model.FileName2;
            content.FileName3   = model.FileName3;
            content.Type        = model.Type;
            content.ContentId   = model.ContentId;
            content.Description = model.Description;
            content.Ext         = model.Ext;
            content.FileSize    = model.FileSize;
            content.FileSize2   = model.FileSize2;
            content.FileSize3   = model.FileSize3;
            content.IsSelected  = model.IsSelected;
            content.IsPublish   = model.IsPublic;


            _contentFileService.UpdateContentFile(content, model.Photo, model.Video, model.Video2, model.Video3);

            return(RedirectToAction(nameof(Index), new { type = content.Type }));
        }
Ejemplo n.º 2
0
        public ActionResult LikeItem([FromBody] PageLimitViewModel model)
        {
            if (model.Kind == "album")
            {
                var p = _categoryService.FindByIdAsync(model.Id, false).Result;

                if (model.Action == "like")
                {
                    p.LikeCount = p.LikeCount + 1;
                }
                else if (model.Action == "dislike")
                {
                    p.LikeCount = p.LikeCount - 1;
                }

                _categoryService.UpdateCategory(p, null, null, null, null);

                return(Ok(p.LikeCount));
            }

            if (model.Kind == "music")
            {
                var p = _contentService.FindByIdAsync(model.Id).Result;

                if (model.Action == "like")
                {
                    p.LikeCount = p.LikeCount + 1;
                }
                else if (model.Action == "dislike")
                {
                    p.LikeCount = p.LikeCount - 1;
                }

                _contentService.UpdateContent(p, null, null, null, null, null, null, null, null, null);

                return(Ok(p.LikeCount));
            }


            if (model.Kind == "artist")
            {
                var p = _tagService.FindByIdAsync(model.Id).Result;

                if (model.Action == "like")
                {
                    p.LikeCount = p.LikeCount + 1;
                }
                else if (model.Action == "dislike")
                {
                    p.LikeCount = p.LikeCount - 1;
                }

                _tagService.UpdateTag(p, null);

                return(Ok(p.LikeCount));
            }

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

                if (model.Action == "like")
                {
                    p.LikeCount = p.LikeCount + 1;
                }
                else if (model.Action == "dislike")
                {
                    p.LikeCount = p.LikeCount - 1;
                }
                _contentFileService.UpdateContentFile(p, null, null, null, null);

                return(Ok(p.LikeCount));
            }


            return(Ok());
        }