public async Task <IActionResult> FindIconsFromUrl([FromBody] EntitySetter data)
        {
            //Console.Write(data.Title);
            var newIcons = await _desktopRepository.GetNewIcons(this.UserId, data);

            return(Json(newIcons));
        }
        public async Task <IActionResult> GetFolderInfo([FromBody] EntitySetter entity)
        {
            var folderId   = new Guid(entity.FolderId);
            var folderInfo = await _desktopRepository.GetFolderInfoAsync(folderId, folderId);

            return(Json(folderInfo));
        }
        public async Task <IActionResult> CreateFolder([FromBody] EntitySetter folder)
        {
            // Console.Write(folder.Title);
            var newFolder = await _desktopRepository.CreateFolderAsync(this.UserId, folder);

            return(Json(newFolder));
        }
        public async Task <IActionResult> GetUseremail([FromBody] EntitySetter folder)
        {
            // Console.Write(folder.Title);
            var userEmail = await _userRepository.GetUserEmail(this.UserId);

            return(Json(userEmail));
        }
        public async Task <IActionResult> ChangeTitle([FromBody] EntitySetter entity)
        {
            string tagsString = null;

            if (entity.tags != null)
            {
                foreach (var tag in entity.tags)
                {
                    string tagT = tag.Trim();
                    if (!string.IsNullOrEmpty(tagT))
                    {
                        tagsString += $"{tagT}||";
                    }
                }
                if (tagsString != null)
                {
                    if (tagsString.Length > 2)
                    {
                        tagsString = tagsString.Substring(0, tagsString.Length - 2);
                        if (tagsString.Length > 200)
                        {
                            tagsString = tagsString.Substring(0, 200);
                        }
                    }
                }
            }


            var icon = await _desktopRepository.ChangeEntityTitleAsync(entity, this.UserId, tagsString);

            return(Json(icon));
        }
        public async Task <IActionResult> UnFollowFolder([FromBody] EntitySetter entity)
        {
            var folderId   = new Guid(entity.FolderId);
            var unfollowed = await _desktopRepository.UnFollowFolder(this.UserId, folderId);

            return(Json(unfollowed));
        }
        public async Task RemoveEntity([FromBody] EntitySetter entity)
        {
            // Console.WriteLine("REMOVING  "+ entity.Id);
            await _desktopRepository.RemoveEntity(this.UserId, entity.Id, entity.Type);

            //return Json(icons);
        }
        public async Task <IActionResult> ChangeLocation([FromBody] EntitySetter editYoutube)
        {
            await _songRepository.ChangeLocation(editYoutube.Id, editYoutube.Left, editYoutube.Top);

            await _movieRepository.ChangeLocation(editYoutube.Id, editYoutube.Left, editYoutube.Top);

            return(Json(editYoutube));
        }
        public async Task <IActionResult> AddIcon([FromBody] EntitySetter icon)
        {
            string tagsString = "";

            if (icon.tags != null)
            {
                foreach (var tag in icon.tags)
                {
                    string tagT = tag.Trim();
                    if (!string.IsNullOrEmpty(tagT))
                    {
                        tagsString += $"{tagT}||";
                    }
                }
                if (tagsString.Length > 2)
                {
                    tagsString = tagsString.Substring(0, tagsString.Length - 2);
                }
            }

            if (icon.Type == "YT" || icon.Type == "MOVIE")
            {
                var added = await _desktopRepository.AddYouTubeAsync(icon, this.UserId, tagsString);

                return(Json(added));
            }
            if (icon.Type == "SPOTIFY")
            {
                var added = await _desktopRepository.AddSpotifyAsync(icon, this.UserId, tagsString);

                return(Json(added));
            }
            if (icon.Type == "IMG" || icon.Type == "BOOK")
            {
                var added = await _desktopRepository.AddImageAsync(icon, this.UserId, tagsString);

                return(Json(added));
            }
            return(Json(false));
        }
 public async Task MoveEntityFromFolder([FromBody] EntitySetter entity)
 {
     await _desktopRepository.MoveEntityFromFolder(this.UserId, entity.Id, entity.Type);
 }
        public async Task <IActionResult> ShareFolder([FromBody] EntitySetter entity)
        {
            var folder = await _desktopRepository.EditFolder(this.UserId, entity);

            return(Json(folder));
        }
        public async Task <IActionResult> AddToFolder([FromBody] EntitySetter en)
        {
            var data = await _desktopRepository.AddEntityToFolder(this.UserId, en.ParentId, en.Id, en.Type);

            return(Json(data));
        }