public void AdminPage_NotNull() { // Arrange AdminPageController controller = new AdminPageController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result); }
void GetGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.ToLower() != "add") { return; } var row = (e.CommandSource as Control).Parent.Parent as GridViewRow; var htd = new Hashtable(); foreach (TemplateField tf in GridViewManager1.GridView.Columns) { var item = tf.FooterTemplate as GenericItem; if (item == null) { continue; } try { foreach (DictionaryEntry de in item.ExtractValues(row)) { htd.Add(de.Key, de.Value); } } catch (Exception ex) { Exceptions.Logger.Error(ex); HtmlHelper.Alert(ex.Message, Page); return; } } try { var ctrl = new AdminPageController(); var info = new AdminPageInfo(); foreach (System.Reflection.PropertyInfo property in CBO.GetPropertyInfo(typeof(AdminPageInfo))) { if (htd[property.Name] != null) { property.SetValue(info, htd[property.Name], null); } } ctrl.InsertAdminPage(info); GridViewManager1.GridView.PageIndex = GridViewManager1.GridView.PageCount; GridViewManager1.LoadData(); } catch (Exception ex) { Exceptions.Logger.Error(ex); HtmlHelper.Alert(ex.Message, Page); } }
public override SiteMapNode GetParentNode(SiteMapNode node) { if (node == null) { return(null); } var id = int.Parse(node.Key); var ctrl = new AdminPageController(); var parentId = ctrl.GetAdminPage(id).ParentID; if (parentId != Null.NullInteger && parentId != id) { var parent = ctrl.GetAdminPage(parentId); if (parent.Visible) { return(new SiteMapNode(this, parent.AdminPageID.ToString(), (parent.Source == Null.NullString ? "" :parent.Link), parent.Name)); } } return(null); }
//Maybe don't create lists for each faction. Dynamically build the player deck using in mem queries from the gAllCards. Don't work twice void Application_Start(object sender, EventArgs e) { // Code that runs on application startup AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); try { // Setup an AD client. ad = new ActiveDirectory(HostingEnvironment.MapPath(CONFIG_ITEM_DIRECTORY), ACTIVE_DIRECTORY_CONFIGURATION_ITEM_NAME); } catch (System.ArgumentNullException ex) { //If the file doesn't exist, or if it's 0 bytes. Note that as of this writing, a 0-byte file will be created if it does not already exist. //System.IO.FileNotFoundException might be a better fit... Console.WriteLine("The file {0}{1}, does not exist, please create it in Astrolabe from the template template.{1}, exception is: {2}", CONFIG_ITEM_DIRECTORY, ACTIVE_DIRECTORY_CONFIGURATION_ITEM_NAME, ex.Source); } catch (System.ArgumentException ex) { //Hits here if the info in ACTIVE_DIRECTORY_CONFIGURATION_ITEM_NAME was not valid. Console.WriteLine("There was a problem with your AD config file {0}{1}, please create it in Astrolabe from the template template.{1}, exception is: {2}", CONFIG_ITEM_DIRECTORY, ACTIVE_DIRECTORY_CONFIGURATION_ITEM_NAME, ex.Source); } // Get our SQL connection string. ConfigurationItem sqlConfig = new ConfigurationItem(HostingEnvironment.MapPath(CONFIG_ITEM_DIRECTORY), DB_CONFIGURATION_ITEM_NAME, true); connectionString = sqlConfig.Value; // Setup the application config gwentAppConfig = new ConfigurationItem(HostingEnvironment.MapPath(CONFIG_ITEM_DIRECTORY), GWENTAPP_CONFIGURATION_ITEM_NAME, false); if (System.IO.File.Exists(gwentAppConfig.FilePath)) { if (gwentAppConfig.Value.Length > 1) { try { //Read the options gAppOptions = (AdminPageController.ReadAppOptions(gwentAppConfig.Value)); //Check for valid data if (gAppOptions.MaxDeckSize < 1) { //If unable to, recreate as defaults bool writesuccess = AdminPageController.WriteOptions(gwentAppConfig.FilePath, new AppOptions(), true); gAppOptions = (AdminPageController.ReadAppOptions(gwentAppConfig.Value)); } } catch { } } else { //If unable to, recreate as defaults bool writesuccess = AdminPageController.WriteOptions(gwentAppConfig.FilePath, new AppOptions(), true); gAppOptions = (AdminPageController.ReadAppOptions(gwentAppConfig.Value)); } } else { //If unable to, recreate as defaults bool writesuccess = AdminPageController.WriteOptions(gwentAppConfig.FilePath, new AppOptions(), true); gAppOptions = (AdminPageController.ReadAppOptions(gwentAppConfig.Value)); } //Map path to pictures pictureMapPath = HostingEnvironment.MapPath(PICTURE_DIRECTORY); //Fill the lists of cards, leaders and factions here DatabaseRead(); }