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

            AdminCollectionEditNameRequest request = Utility.ParseJson<AdminCollectionEditNameRequest>(jsonString);
            Collection collection = Collection.GetById(request.id);

            if (collection == null)
            {
                ajax.BadRequest();
                return;
            }

            AdminCollectionEditNameResponse response = new AdminCollectionEditNameResponse();

            if (request.name == null || request.name == "")
            {
                response.name = collection.Name;
            }
            else
            {
                request.name = Utility.Remove4PlusBytesUtf8Chars(request.name);

                if (request.name.Length > 50)
                {
                    request.name = request.name.Substring(0, 50);
                }

                if (!Collection.CheckNewCollectionName(request.name))
                {
                    response.status = 1;
                }
                else
                {
                    response.status = 0;
                    collection.Name = request.name;
                    collection.MarkFolderCacheDirty();
                    collection.Save();
                }
            }

            ajax.ReturnJson(response);
        }
 private void GetNameSuccess(AdminCollectionEditNameResponse response)
 {
     Show();
     jQuery.Select("#admin-collection-editname-name").Value(response.name).Focus();
 }
        private void SubmitSuccess(AdminCollectionEditNameResponse response)
        {
            submittingForm = false;

            switch (response.status)
            {
                case 0:
                    Hide();
                    collectionsModule.Refresh();
                    break;
                case 1:
                    ErrorModal.ShowError(Strings.Get("DuplicateCollectionName"));
                    break;
                default:
                    ErrorModal.ShowError(Strings.Get("UnknownError"));
                    break;
            }
        }