Exemplo n.º 1
0
        public CreateSiteOptions ToCreateSiteOptions()
        {
            var options = new CreateSiteOptions()
            {
                RepositoryName = Repository,
                MembershipName = Membership,
            };

            return options;
        }
Exemplo n.º 2
0
        public virtual ActionResult ImportSite(ImportSiteModel model, string @return)
        {
            var data = new JsonResultData(ModelState);

            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {
                    Site parent = null;
                    if (!string.IsNullOrEmpty(model.Parent))
                    {
                        parent = new Site(model.Parent);
                    }
                    var options = new CreateSiteOptions()
                        {
                            MembershipName = model.Membership,
                            RepositoryName = model.Repository,
                            UserName = User.Identity.Name
                        };
                    Site createdSite = null;
                    if (Request.Files.Count > 0)
                    {

                        createdSite = ServiceFactory.SiteManager.Create(parent, model.Name, Request.Files[0].InputStream, options);
                    }
                    else
                    {
                        var packageFile = _importedSiteManager.GetItemTemplate("", model.File);
                        createdSite = ServiceFactory.SiteManager.Create(parent, model.Name, packageFile.TemplateFile, options);
                    }

                    resultData.RedirectUrl = Url.Action("SiteMap", new { controller = "Home", siteName = createdSite.FullName });
                });
            }
            return Json(data);
        }