Пример #1
0
        public ActionResult UploadSiteLogo(string subplatform, FileViewModel fileViewModel)
        {
            if (ModelState.IsValid)
            {
                Subplatform subplatformToChange = SubplatformMgr.GetSubplatform(subplatform);
                var         iconUrl             = "";
                string      _FileName           = "";
                if (fileViewModel.file != null)
                {
                    if (fileViewModel.file.ContentLength > 0)
                    {
                        //_FileName = Path.GetFileName(fileViewModel.file.FileName);
                        //var name = "Site_Logo";
                        //var newName = name + "." + _FileName.Substring(_FileName.IndexOf(".") + 1);
                        //string _path = Path.Combine(Server.MapPath("~/Content/Images/Site/"), newName);
                        //fileViewModel.file.SaveAs(_path);
                        //iconUrl = @"~/Content/Images/Site/" + newName;
                        ImageConverter imgCon = new ImageConverter();
                        var            img    = Image.FromStream(fileViewModel.file.InputStream);
                        SubplatformMgr.ChangeSubplatformSetting(subplatformToChange, new SubplatformSetting
                        {
                            SettingName = Setting.Platform.SITE_ICON_URL,
                            Value       = null,
                            Image       = (byte[])imgCon.ConvertTo(img, typeof(byte[])),
                            IsEnabled   = true,
                            Subplatform = subplatformToChange
                        });
                    }
                }

                return(RedirectToAction("PlatformSettings", "Subplatform"));
            }

            return(RedirectToAction("PlatformSettings", "Subplatform"));
        }