private ActionResult Upload(ThemeUploader uploader)
        {
            try
            {
                uploader.Install();
            }
            catch (ThemeUploadException ex)
            {
                return this.AjaxFail(ex.Message, HttpStatusCode.BadRequest);
            }
            catch (ThemeInstallException ex)
            {
                return this.AjaxFail(ex.Message, HttpStatusCode.BadRequest);
            }

            return Json(new {success = true}, JsonRequestBehavior.AllowGet);
        }
        public ActionResult UploadTheme()
        {
            if (this.Request.Files.Count > 1)
            {
                return this.AjaxFail("Only single file may be uploaded", HttpStatusCode.BadRequest);
            }

            var file = this.Request.Files[0];
            if (file == null)
            {
                return this.AjaxFail("No file was uploaded", HttpStatusCode.BadRequest);
            }

            try
            {
                var uploader = new ThemeUploader(file);
                return Upload(uploader);
            }
            catch (ThemeUploadException ex)
            {
                return this.AjaxFail(ex.Message, HttpStatusCode.InternalServerError);
            }
        }
        public ActionResult UploadTheme(string url)
        {
            Uri uri;
            bool result = Uri.TryCreate(url, UriKind.Absolute, out uri) &&
                          (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps);

            if (result.Equals(false))
            {
                return this.AjaxFail("Invalid URL", HttpStatusCode.BadRequest);
            }

            try
            {
                var uploader = new ThemeUploader(uri);
                return this.Upload(uploader);
            }
            catch (ThemeUploadException ex)
            {
                return this.AjaxFail(ex.Message, HttpStatusCode.InternalServerError);
            }
        }
Exemple #4
0
        private ActionResult Upload(ThemeUploader uploader)
        {
            try
            {
                uploader.Install(this.Tenant);
            }
            catch(ThemeUploadException ex)
            {
                return this.Failed(ex.Message, HttpStatusCode.BadRequest);
            }
            catch(ThemeInstallException ex)
            {
                return this.Failed(ex.Message, HttpStatusCode.BadRequest);
            }

            return this.Ok();
        }