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")); }