Beispiel #1
0
        //Methods for loading and saving...
        public static void LoadAlbums(string fichero)
        {
            Log.Instance.PrintMessage("Loading albums stored at " + fichero, MessageType.Info, "cargarAlbumes(string)");
            Stopwatch crono = Stopwatch.StartNew();

            using (StreamReader lector = new StreamReader(fichero))
            {
                string LineaJson = "";
                while (!lector.EndOfStream)
                {
                    LineaJson = lector.ReadLine();
                    AlbumData a = JsonConvert.DeserializeObject <AlbumData>(LineaJson);
                    a.Genre = Genres[FindGenre(a.Genre.Id)];
                    Collection.AddAlbum(ref a);
                    a.CanBeRemoved = true;
                }
            }
            crono.Stop();
            Log.Instance.PrintMessage("Loaded " + Collection.Albums.Count + " albums without problems", MessageType.Correct, crono, TimeType.Milliseconds);
            ReloadView();
        }
        public ActionResult Create(int collectionId, string albumName, string artist)
        {
            Dictionary <string, object> model = new Dictionary <string, object>();
            Collection foundCollection        = Collection.Find(collectionId);
            Album      newAlbum = new Album(albumName, artist);

            foundCollection.AddAlbum(newAlbum);
            List <Album> collectionAlbums = foundCollection.Albums;

            model.Add("albums", collectionAlbums);
            model.Add("collection", foundCollection);
            return(View("Show", model));
        }