Beispiel #1
0
        public void SaveNewWebpage()
        {
            var newWebPage = new WepPageModel();

            newWebPage.Address     = AddedWebPageAddress;
            newWebPage.Description = AddedWebPageDescription;

            foreach (TagModel tag in AddedWebPageTags)
            {
                newWebPage.Tags.Add(tag);
            }


            var rayCarrotDataAccess = new RayRabbitDataAccess();

            rayCarrotDataAccess.SetFileNameToGenericName <WepPageModel>();
            rayCarrotDataAccess.SetPathToSolutionPath();
            // this needs to be a seperate method to add the new web page
            //CurrentWebPages.Add(newWebPage);

            List <WepPageModel> WebPageToSaveList = new List <WepPageModel>();

            WebPageToSaveList.Add(newWebPage);
            //WebPageToSaveList = ConvertBindableCollectionToList<WepPageModel>(CurrentWebPages);
            rayCarrotDataAccess.SaveObjectsToXMLFile <List <WepPageModel>, WepPageModel>(WebPageToSaveList);
            SetTheAddedInfoBoxesToBlank();
            TextBoxVisible  = false;
            CurrentWebPages = new BindableCollection <WepPageModel>();
            var receivedRecords = rayCarrotDataAccess.GetObjectsFromXMLFile <List <WepPageModel> >();

            foreach (WepPageModel webPage in receivedRecords)
            {
                CurrentWebPages.Add(webPage);
            }
        }
        static void Main(string[] args)
        {
            bool mQuitProgram          = false;
            List <WepPageModel> mPages = new List <WepPageModel>();

            while (!mQuitProgram)
            {
                Console.WriteLine("Enter Web address ('END' or 'return' to quit): ");
                string mWebAddress = Console.ReadLine();

                mQuitProgram = mWebAddress.Equals("END", StringComparison.CurrentCultureIgnoreCase);
                if (!mQuitProgram)
                {
                    mQuitProgram = mWebAddress.Equals("");
                }
                if (!mQuitProgram)
                {
                    bool mQuitEnteringTags = false;

                    WepPageModel PageModel = new WepPageModel(mWebAddress);

                    while (!mQuitEnteringTags)
                    {
                        // initialize loop variables
                        int i = 1; bool emptyTag = false;
                        // loop
                        do
                        {
                            Console.WriteLine($"Enter Tag {i}: ");
                            TagModel tag = new TagModel(Console.ReadLine());

                            emptyTag = (string.IsNullOrEmpty(tag.Tagline));

                            if (!emptyTag)
                            {
                                PageModel.Tags.Add(tag);

                                i++;
                            }
                        } while (!emptyTag);

                        mQuitEnteringTags = true;
                    }

                    mPages.Add(PageModel);
                }
            }

            Console.WriteLine("finished entering webpages");

            var rayCarrotDataAccess = new RayRabbitDataAccess();

            rayCarrotDataAccess.SetFileNameToGenericName <WepPageModel>();
            rayCarrotDataAccess.SetPathToSolutionPath();
            rayCarrotDataAccess.SaveObjectsToXMLFile <List <WepPageModel>, WepPageModel>(mPages);

            List <WepPageModel> receivedPages = rayCarrotDataAccess.GetObjectsFromXMLFile <List <WepPageModel> >();
        }