Exemplo n.º 1
0
        public HttpResponseMessage CreateStateInfo(CompendiumModel model)
        {
            HttpResponseMessage result = new HttpResponseMessage();

            try
            {
                using (OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["cardcolv"].ConnectionString))
                {
                    OracleCommand cmd = new OracleCommand()
                    {
                        Connection = con
                    };
                    cmd.CommandText = "INSERT INTO cardcolv.state_program_list (STATE_ID, STATE_NAME) VALUES (" + model.ID + ",'" + model.Name + "')";

                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                    }
                    catch (System.Exception ex)
                    {
                        throw new System.Exception(ex.Message);
                    }
                }
            }
            catch (System.Exception ex)
            {
                result = new HttpResponseMessage()
                {
                    Content = new StringContent("status: " + ex.ToString(), Encoding.UTF8, "application/json")
                };
            }
            return(result);
        }
Exemplo n.º 2
0
        public HttpResponseMessage SetStateInfo(CompendiumModel model)
        {
            HttpResponseMessage result = new HttpResponseMessage();

            try
            {
                using (OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["cardcolv"].ConnectionString))
                {
                    OracleCommand cmd = new OracleCommand()
                    {
                        Connection = con
                    };

                    cmd.CommandText = "UPDATE cardcolv.state_program_list SET STATE_NAME = '" + model.Name + "' WHERE STATE_ID = " + model.ID;

                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                    }
                    catch (System.Exception ex)
                    {
                        throw new System.Exception(ex.Message);
                    }
                }
            }
            catch (System.Exception ex)
            {
                result = new HttpResponseMessage()
                {
                    Content = new StringContent("status: failed", Encoding.UTF8, "application/json")
                };
            }
            return(result);
        }
Exemplo n.º 3
0
 public ContentPageViewModel(CompendiumModel compendium, ContentPageModel model) : base(model.Header)
 {
     _Compendium = compendium;
     _Model      = model;
     foreach (FilterGroup group in _Model.FilterGroups)
     {
         _FilterGroups.Add(new FilterGroupViewModel(group));
     }
 }
        public SpellPageViewModel(CompendiumModel compendium) : base("Spells")
        {
            _Compendium = compendium;

            // Initialize filters
            _ClassFilters = new ObservableList <FilterFlagViewModel <ClassModel> >(
                _ClassViewerModel.Content
                .Where(c => c.IsRoot && c.ShowInFilterList && c.HasSpells)
                .Select(c => GetClassFilterObject(c)));

            _SchoolFilters = new ObservableList <FilterFlagViewModel <SpellSchool> >(
                _SpellViewerModel.SpellSchools.Select(s => new FilterFlagViewModel <SpellSchool>(s, () => s.Name)));

            _ComponentFilters = new ObservableList <FilterFlagViewModel <SpellComponent> >(
                _SpellViewerModel.Components.Select(c => new FilterFlagViewModel <SpellComponent>(c, () => c.Name)));

            _SourceFilters = new ObservableList <FilterFlagViewModel <ContentSource> >(
                _Compendium.ContentSources.Select(s => new FilterFlagViewModel <ContentSource>(s, () => s.Name)));
        }
 public CharacterViewModel(CompendiumModel compendium, SelectionModel <CharacterModel> selection)
 {
     _Compendium = compendium;
     _Selected   = selection;
 }
 public CompendiumViewModel(CompendiumModel model)
 {
     _Model = model;
 }
Exemplo n.º 7
0
        //public object CharacterVM => ViewModel(() => new CharacterViewModel(_Compendium, _CharacterSelection));


        public ViewModelLocator()
        {
            _Compendium = new CompendiumModel();
            _SpellPage  = new SpellPageModel(_Compendium);
            _ClassPage  = new ClassPageModel(_Compendium);
            _AllPagesVM = new List <Page>();

            if (DesignMode)
            {
            }
            else
            {
                string dataDir = Path.Combine(
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                    DATA_FOLDER);
                string indexFile = Path.Combine(dataDir, INDEX);

                if (!File.Exists(indexFile))
                {
                    throw new ArgumentNullException(indexFile + " not found.");
                }

                // Parse the index file that contains all the other pages that will be loaded
                //dynamic index = JsonConvert.DeserializeObject(ResourceHelper.ReadTextFromFile(indexFile));
                Index_Json index = JsonConvert.DeserializeObject <Index_Json>(ResourceHelper.ReadTextFromFile(indexFile));

                // Load spells and supporting info
                if (index.spells != null)
                {
                    _Compendium.AddContentPage(LoadSpellInfo(dataDir, index));
                }

                // Load classes
                if (index.classes != null && index.classSpells != null)
                {
                }

                // Load all other pages
                if (index.otherPages != null)
                {
                    foreach (var page in index.otherPages)
                    {
                        // TODO: More error checking
                        if (page.title == null || page.content == null)
                        {
                            continue;
                        }

                        ContentPageModel cpm = new ContentPageModel(_Compendium)
                        {
                            Header = page.title
                        };
                        cpm.DeserializeContent(
                            dataDir,
                            JsonConvert.DeserializeObject <ContentPage_Json>(
                                ReadFileFromIndex(Path.Combine(dataDir, page.content))));

                        _Compendium.OtherPages.Add(cpm);
                    }
                }

                #region old
                // Load the content sources first, so that other content can use the sources.
                // Sources being PHB, EE, Volo's, SCAG, etc.
                //_Compendium.DeserializeContentSources(
                //    JsonConvert.DeserializeObject<Sources_Json>(
                //        ReadFileFromIndex(
                //            Path.Combine(dataDir, index.sources))));

                //// If all of the spell json files are present, load the spells
                //if (index.spells != null && index.spellSchools != null && index.spellComponents != null)
                //{
                //    // Do schools and components first since the spells rely on those
                //    _SpellPage.DeserializeSchools(
                //        JsonConvert.DeserializeObject<Schools_Json>(
                //            ReadFileFromIndex(
                //                Path.Combine(dataDir, index.spellSchools))));
                //    _SpellPage.DeserializeComponents(
                //        JsonConvert.DeserializeObject<Components_Json>(
                //            ReadFileFromIndex(
                //                Path.Combine(dataDir, index.spellComponents))));
                //    _SpellPage.DeserializeSpells(
                //        JsonConvert.DeserializeObject<Spells_Json>(
                //            ReadFileFromIndex(Path.Combine(dataDir, index.spells))));
                //}

                //// If both class json files are present, load the classe
                //if (index.classes != null && index.classSpells != null)
                //{
                //    // Load classes firest since they need to be loaded before binding classes with their spell lists
                //    _ClassPage.DeserializeContent(
                //        dataDir,
                //        JsonConvert.DeserializeObject<Classes_Json>(
                //            ReadFileFromIndex(Path.Combine(dataDir, index.classes))));
                //    _ClassPage.DeserializeClassSpells(
                //        ReadFileFromIndex(Path.Combine(dataDir, index.classSpells)));
                //}

                //// Load the rest of the content from the "otherPages" into their own content viewers
                //if (index.otherPages != null)
                //{
                //    foreach (var page in index.otherPages)
                //    {
                //        // TODO: Add dialog about incorrect json
                //        if (page.title == null || page.content == null)
                //            continue;

                //        ContentPageModel cpm = new ContentPageModel(_Compendium)
                //        {
                //            Header = page.title
                //        };
                //        cpm.DeserializeContent(
                //            dataDir,
                //            JsonConvert.DeserializeObject<ContentPage_Json>(
                //                ReadFileFromIndex(Path.Combine(dataDir, page.content))));

                //        _Compendium.OtherPages.Add(cpm);
                //    }
                //}
                #endregion
            }
        }
Exemplo n.º 8
0
 public HttpResponseMessage SetState(CompendiumModel model)
 {
     //CompendiumModel model = new CompendiumModel() { ID = 4, Name = "test4" };
     return(SetStateInfo(model));
 }