public async Task<ActionResult> Index() { var availableSiteTemplates = await _siteTemplateService.Read(); var model = new SiteTemplateCreationModel {SiteCreationTemplates = availableSiteTemplates}; return View(model); }
public ActionResult CreateSite(SiteTemplateCreationModel siteTemplateCreationModel) { User spUser = null; Site spSite = null; var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); using (var clientContext = spContext.CreateUserClientContextForSPHost()) { if (clientContext != null) { spUser = clientContext.Web.CurrentUser; clientContext.Load(spUser, user => user.Email); clientContext.ExecuteQuery(); spSite = clientContext.Site; clientContext.Load(spSite, site => site.Url); clientContext.ExecuteQuery(); } } var request = new ActionRequest { RequestID = Guid.NewGuid(), Name = siteTemplateCreationModel.Name, Description = siteTemplateCreationModel.Description, SiteTemplateName = siteTemplateCreationModel.SelectedSiteCreationTemplate, User = spUser.Email, Url = spSite.Url, TenantName = new Uri(spSite.Url).Host.Split('.')[0] }; _createRequestService.PutCreateRequestInQueue(request); _logService.SendLog(request, State.Queued); return RedirectToAction("Queue", "Log", new { SPHostUrl = Request.QueryString["SPHostUrl"] }); }