Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("id,content,tags,reference,addedOn")] til til)
        {
            if (id != til.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(til);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tilExists(til.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(til));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("id,content,tags,reference,addedOn")] til til)
        {
            if (ModelState.IsValid)
            {
                _context.Add(til);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(til));
        }
    //______________________________________________________________________________________________



    public void writeInfo()
    {
        /*
         *      string path = "Assets/Resources/test.txt";
         *      File.WriteAllText(path, "");
         *      //Write some text to the test.txt file
         *      StreamWriter writer = new StreamWriter(path, true);
         *      // writer.WriteLine("sTest");
         *
         *      for (int i = 0; i < Tiles.Count; i++)
         *      {
         *          int no = Tiles[i].GetComponent<VisitCounter>().NoOfTimesEntered;
         *          writer.WriteLine(no);
         *      }
         *      writer.Close();
         *
         *      //Re-import the file to update the reference in the editor
         *      AssetDatabase.ImportAsset(path);
         *      TextAsset asset = (TextAsset)Resources.Load("test");
         *
         *      //Print the text from the file
         *      Debug.Log(asset.text);
         */
        xmlslayer excuter = new xmlslayer();

        excuter.tile.Clear();

        for (int i = 0; i < Tiles.Count; i++)
        {
            til Tile = new til();
            Tile.timeEntered = Tiles[i].GetComponent <VisitCounter>().NoOfTimesEntered;
            Tile.threat      = Tiles[i].GetComponent <VisitCounter>().threat;
            excuter.tile.Add(Tile);
        }
        excuter.Save(Path.Combine(Application.dataPath, "Tiles.xml"));
    }