Example #1
0
        public ActionResult OrganisationPartialCreate(string subplatform, OrganisationEditModel organisationEditModel)
        {
            if (ModelState.IsValid)
            {
                Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
                var         iconUrl     = "";
                byte[]      image       = null;
                string      _FileName   = "";
                if (organisationEditModel.file != null)
                {
                    if (organisationEditModel.file.ContentLength > 0)
                    {
                        //_FileName = Path.GetFileName(organisationEditModel.file.FileName);
                        //var username = organisationEditModel.Name.ToString();
                        //var newName = username + "." + _FileName.Substring(_FileName.IndexOf(".") + 1);
                        //string _path = Path.Combine(Server.MapPath("~/Content/Images/Organisations/"), newName);
                        //organisationEditModel.file.SaveAs(_path);
                        //iconUrl               = @"~/Content/Images/Organisations/" + newName;
                        ImageConverter imgCon = new ImageConverter();
                        var            img    = Image.FromStream(organisationEditModel.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;
                }

                Theme theme = null;

                if (organisationEditModel.ThemeId != null)
                {
                    theme = itemMgr.GetTheme((int)organisationEditModel.ThemeId);
                    itemMgr.AddOrganisation(organisationEditModel.Name, organisationEditModel.FullName, organisationEditModel.SocialMediaLink, new List <Theme> {
                        theme
                    }, iconUrl, false, Subplatform, image);
                }
                else
                {
                    itemMgr.AddOrganisation(organisationEditModel.Name, organisationEditModel.FullName, organisationEditModel.SocialMediaLink, null, iconUrl, false, Subplatform, image);
                }

                return(RedirectToAction("ItemBeheer", "Item"));
            }

            return(RedirectToAction("ItemBeheer", "Item"));
        }