public override void HandleRequest(string jsonString, AjaxBase ajax)
        {
            if (!User.IsAdminLoggedIn(ajax))
            {
                ajax.Unauthorized();
                return;
            }

            AdminMangaAddRequest request = Utility.ParseJson<AdminMangaAddRequest>(jsonString);
            Collection collection = Collection.GetById(request.cid);

            if (request.path == null || request.path == "" || collection == null)
            {
                ajax.BadRequest();
                return;
            }

            AdminMangaAddResponse response = new AdminMangaAddResponse();

            if ((request.path = Manga.CheckMangaPath(request.path)) == null || !Utility.IsValidStringForDatabase(request.path))
            {
                response.status = 1;
            }
            else if (request.path.IndexOf(collection.Path, StringComparison.InvariantCultureIgnoreCase) != 0)
            {
                response.status = 2;
            }
            else if (Manga.CheckMangaType(request.path) == -1)
            {
                response.status = 3;
            }
            else
            {
                response.status = 0;
                Manga.CreateNewManga(collection, request.path).Save();
                collection.MarkFolderCacheDirty();
            }

            ajax.ReturnJson(response);
        }
Esempio n. 2
0
        private void SubmitSuccess(AdminMangaAddResponse response)
        {
            submittingForm = false;

            switch (response.status)
            {
                case 0:
                    Hide();
                    mangasModule.Refresh();
                    break;
                case 1:
                    ErrorModal.ShowError(Strings.Get("FileNotFoundOrAlreadyAdded"));
                    break;
                case 2:
                    ErrorModal.ShowError(Strings.Get("PathNotUnderCollection"));
                    break;
                case 3:
                    ErrorModal.ShowError(Strings.Get("InvalidFileType"));
                    break;
                default:
                    ErrorModal.ShowError(Strings.Get("UnknownError"));
                    break;
            }
        }