public ViewResult Settings(string workspace, string collection)
 {
   string view = "AdminSettings";
   AdminModel m = null;
   if (Scope.IsEntireSite)
   {
     var esm = TempData["model"] as AdminSettingsEntireSiteModel;
     if (esm == null)
     {
       esm = new AdminSettingsEntireSiteModel();
       esm.SiteAddress = AppService.Base;
       esm.DefaultSubdomain = AppService.DefaultSubdomain;
       esm.ServiceType = AppService.ServiceType.ToString();
       esm.Secure = AppService.Secure;
     }
     view = "AdminSettingsEntireSite";
     m = esm;
   }
   else if (Scope.IsWorkspace)
   {
     var wm = TempData["model"] as AdminSettingsWorkspaceModel;
     if (wm == null)
     {
       wm = new AdminSettingsWorkspaceModel();
       //wm.Workspace = workspace;
       wm.Title = Workspace.Title.Text;
       wm.Subtitle = Workspace.Subtitle != null ? Workspace.Subtitle.Text : null;
       wm.Name = Workspace.Name;
     }
     view = "AdminSettingsWorkspace";
     m = wm;
   }
   else
   {
     var cm = TempData["model"] as AdminSettingsCollectionModel;
     if (cm == null)
     {
       cm = new AdminSettingsCollectionModel();
       cm.CollectionId = Collection.Id;
       cm.Title = Collection.Title.Text;
       cm.Subtitle = Collection.Subtitle != null ? Collection.Subtitle.Text : null;
       cm.Owner = Collection.Id.Owner;
       cm.Name = Collection.Id.Collection;
       cm.Dated = Collection.Dated;
       cm.Visible = Collection.Visible;
       cm.AnnotationsOn = Collection.AnnotationsOn;
       cm.SyndicationOn = Collection.SyndicationOn;
     }
     view = "AdminSettingsCollection";
     m = cm;
   }
   if (m == null) m = new AdminModel();
   if (TempData["new"] != null) m.Notifications.Add((string)TempData["new"], "was created successfully! Changes may take some time before they appear.");
   else if (TempData["saved"] != null) m.Notifications.Add("Saved", "settings successfully! Changes may take some time before they appear.");
   return View(view, "Admin", m);
 }
    public ActionResult UpdateEntireSite(AdminSettingsEntireSiteModel m)
    {
      try
      {
        AppService.Base = m.SiteAddress;
        AppService.ServiceType = (ServiceType)Enum.Parse(typeof(ServiceType), m.ServiceType);
        AppService.DefaultSubdomain = !string.IsNullOrEmpty(m.DefaultSubdomain) ? m.DefaultSubdomain : null;
        AppService.Secure = m.Secure ?? false;

        AtomPubService.UpdateService(AppService);
        ServerApp.Restart();
        TempData["saved"] = true;
      }
      catch (Exception ex)
      {
        LogService.Error(ex);
        m.Errors.Add(ex.Message);
      }
      TempData["model"] = m;
      return RedirectToAction("Settings");
    }