<commit_before>﻿namespace Jekov.Nevix.Web.ServerApi.Controllers
{
    using Jekov.Nevix.Common.Models;
    using Jekov.Nevix.Common.ViewModels;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Net.Http;
    using System.Web.Http;

    public class MediaFoldersMobileController : BaseApiController
    {
        [HttpGet]
        public HttpResponseMessage GetFolders()
        {
            var currentUser = GetCurrentUser();

            if (currentUser == null)
            {
                return UnauthorizedErrorMessage();
            }

            IEnumerable<MediaFolderMobileViewModel> folders = GetUserFoldersToMobile(currentUser.Id);

            return Request.CreateResponse(HttpStatusCode.OK, folders);
        }

        private IEnumerable<MediaFolderMobileViewModel> GetUserFoldersToMobile(int userId)
        {
            List<MediaFolderMobileViewModel> foldersConverted = new List<MediaFolderMobileViewModel>();
            var folders = Data.Folders.All().Where(f => f.ParentFolderId == null && f.UserId == userId).ToList();

            foreach (var folder in folders)
            {
                foldersConverted.Add(FolderToMobileViewModel(folder));
            }

            return foldersConverted;
        }

        private MediaFolderMobileViewModel FolderToMobileViewModel(MediaFolder folder)
        {
            MediaFolderMobileViewModel root = new MediaFolderMobileViewModel
            {
                Name = folder.Name
            };

            foreach (var file in folder.Folders)
            {
                root.Files.Add(new MediaFileMobileViewModel
                    {
                        Id = file.Id,
                        Name = file.Name
                    });
            }

            foreach (var subFolder in folder.Folders)
            {
                root.Folders.Add(FolderToMobileViewModel(subFolder));
            }

            return root;
        }
    }
}<commit_msg>Fixed bug in mobile folders.<commit_after>﻿namespace Jekov.Nevix.Web.ServerApi.Controllers
{
    using Jekov.Nevix.Common.Models;
    using Jekov.Nevix.Common.ViewModels;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Net.Http;
    using System.Web.Http;

    public class MediaFoldersMobileController : BaseApiController
    {
        [HttpGet]
        public HttpResponseMessage GetFolders()
        {
            var currentUser = GetCurrentUser();

            if (currentUser == null)
            {
                return UnauthorizedErrorMessage();
            }

            IEnumerable<MediaFolderMobileViewModel> folders = GetUserFoldersToMobile(currentUser.Id);

            return Request.CreateResponse(HttpStatusCode.OK, folders);
        }

        private IEnumerable<MediaFolderMobileViewModel> GetUserFoldersToMobile(int userId)
        {
            List<MediaFolderMobileViewModel> foldersConverted = new List<MediaFolderMobileViewModel>();
            var folders = Data.Folders.All().Where(f => f.ParentFolderId == null && f.UserId == userId).ToList();

            foreach (var folder in folders)
            {
                foldersConverted.Add(FolderToMobileViewModel(folder));
            }

            return foldersConverted;
        }

        private MediaFolderMobileViewModel FolderToMobileViewModel(MediaFolder folder)
        {
            MediaFolderMobileViewModel root = new MediaFolderMobileViewModel
            {
                Name = folder.Name
            };

            foreach (var file in folder.Files)
            {
                root.Files.Add(new MediaFileMobileViewModel
                    {
                        Id = file.Id,
                        Name = file.Name
                    });
            }

            foreach (var subFolder in folder.Folders)
            {
                root.Folders.Add(FolderToMobileViewModel(subFolder));
            }

            return root;
        }
    }
}
{'fraction_non_alphanumeric': 0.07628157959283786, 'fraction_numerical': 0.0, 'mean_word_length': 1.7741496598639457, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4337419', 'n_tokens_mistral': 1058, 'n_tokens_neox': 993, 'n_words': 188}