示例#1
0
        public ActionResult EditTheme(int id)
        {
            Theme          item           = itemMgr.GetTheme(id);
            ThemeEditModel themeEditModel = new ThemeEditModel()
            {
                ItemId      = item.ItemId,
                Name        = item.Name,
                IsTrending  = item.IsTrending,
                Description = item.Description
            };

            return(View(themeEditModel));
        }
示例#2
0
        public ActionResult ThemaPartialCreate(string subplatform, ThemeEditModel themeEditModel)
        {
            if (ModelState.IsValid)
            {
                Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
                var         iconUrl     = "";
                string      _FileName   = "";
                byte[]      image       = null;
                if (themeEditModel.file != null)
                {
                    if (themeEditModel.file.ContentLength > 0)
                    {
                        //_FileName = Path.GetFileName(themeEditModel.file.FileName);
                        //var username = themeEditModel.Name.ToString();
                        //var newName = username + "." + _FileName.Substring(_FileName.IndexOf(".") + 1);
                        //string _path = Path.Combine(Server.MapPath("~/Content/Images/Themes/"), newName);
                        //themeEditModel.file.SaveAs(_path);
                        //iconUrl = @"~/Content/Images/Themes/" + newName;

                        ImageConverter imgCon = new ImageConverter();
                        var            img    = Image.FromStream(themeEditModel.file.InputStream);
                        image = (byte[])imgCon.ConvertTo(img, typeof(byte[]));
                    }
                }
                else
                {
                    iconUrl = Subplatform.Settings.Where(p => p.SettingName.Equals(Setting.Platform.DEFAULT_NEW_ITEM_ICON)).First().Value;
                }
                if (themeEditModel.KeywordId is null)
                {
                    Theme theme = itemMgr.AddTheme(themeEditModel.Name, themeEditModel.Description, iconUrl, new List <Keyword>(), themeEditModel.IsTrending, Subplatform, image);
                }
                else
                {
                    Keyword keyword = itemMgr.GetKeyword((int)themeEditModel.KeywordId);
                    Theme   theme   = itemMgr.AddTheme(themeEditModel.Name, themeEditModel.Description, iconUrl, new List <Keyword> {
                        keyword
                    }, themeEditModel.IsTrending, Subplatform, image);
                }


                return(RedirectToAction("ItemBeheer", "Item"));
            }
            return(RedirectToAction("ItemBeheer", "Item"));
        }
示例#3
0
        public ActionResult EditTheme(string subplatform, int id, ThemeEditModel themeEditModel)
        {
            byte[] image = null;

            if (ModelState.IsValid)
            {
                Theme  theme     = itemMgr.GetTheme(themeEditModel.ItemId);
                var    iconUrl   = "";
                string _FileName = "";
                if (themeEditModel.file != null)
                {
                    if (themeEditModel.file.ContentLength > 0)
                    {
                        //_FileName = Path.GetFileName(themeEditModel.file.FileName);
                        //var username = themeEditModel.Name.ToString();
                        //var newName = username + "." + _FileName.Substring(_FileName.IndexOf(".") + 1);
                        //string _path = Path.Combine(Server.MapPath("~/Content/Images/Themes/"), newName);
                        //themeEditModel.file.SaveAs(_path);
                        //iconUrl = @"~/Content/Images/Themes/" + newName;
                        theme.IconURL = iconUrl;
                        ImageConverter imgCon = new ImageConverter();
                        var            img    = Image.FromStream(themeEditModel.file.InputStream);
                        image       = (byte[])imgCon.ConvertTo(img, typeof(byte[]));
                        theme.Image = image;
                    }
                }
                else
                {
                    iconUrl = theme.IconURL;
                }

                theme.IsTrending  = themeEditModel.IsTrending;
                theme.Name        = themeEditModel.Name;
                theme.Description = themeEditModel.Description;
                Keyword keyword = itemMgr.GetKeyword((int)themeEditModel.KeywordId);
                theme.Keywords.Add(keyword);
                itemMgr.ChangeTheme(theme);
                return(RedirectToAction("ItemBeheer", "Item"));
            }
            return(RedirectToAction("ItemBeheer", "Item"));
        }