public ActionResult UploadImage()
        {
            try
            {
                var file = WebImageWrapper.GetImageFromRequest();

                var folderName = $"_{DateTime.Now:yyyyMMdd}_{Guid.NewGuid():N}";
                var info       = Directory.CreateDirectory(Path.Combine(this.UploadFolderFullPath, "temp", folderName));

                file.Resize(1920, 1080)
                .Save(Path.Combine(info.FullName, "0"));

                return(Json(new
                {
                    IsError = false,
                    Name = folderName
                }));
            }
            catch (Exception ex)
            {
                Log.For(typeof(PromotionController)).Error(ex.Message);
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode             = 500;
                return(Json(new { IsError = true, ex.Message }));
            }
        }
Esempio n. 2
0
        public ActionResult UploadLogo()
        {
            try
            {
                var webImage       = WebImageWrapper.GetImageFromRequest();
                var tempFolderPath = Path.Combine(this.UploadTempFolderFullPath, Request.Form.Get(nameof(CompanyViewModel.TempFolderName)));

                new Company().SaveTempLogo(webImage, tempFolderPath);

                return(Json("Ok"));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
        }