Beispiel #1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            Albom albom = db.Albom.Find(id);

            db.Albom.Remove(albom);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
 public ActionResult Edit([Bind(Include = "ID_Alboma,Name,Information")] Albom albom)
 {
     if (ModelState.IsValid)
     {
         db.Entry(albom).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(albom));
 }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "ID_Alboma,Name,Information")] Albom albom)
        {
            if (ModelState.IsValid)
            {
                albom.ID_Alboma = Guid.NewGuid();
                db.Albom.Add(albom);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(albom));
        }
Beispiel #4
0
        private void AddNewSongToAlbom()
        {
            Console.Write("Catalogs: ");
            foreach (var item in this.Catalogs)
            {
                Console.Write($"{item.Name}, ");
            }
            Console.Write("\nEnter name of Catalog in which you what to add new Song: ");
            string  catalogName = Console.ReadLine();
            Catalog catalog     = this.GetCatalog(catalogName);

            if (catalog == null)
            {
                Console.WriteLine($"Can not find Catalog with name {catalogName}");
                return;
            }
            Console.Write($"Alboms in {catalog.Name}: ");
            foreach (var item in catalog.Alboms)
            {
                Console.Write($"{item.Name} by {item.Autrhor.Name}, ");
            }
            Console.Write("\nEnter name of Albom: ");
            string albomName = Console.ReadLine();
            Albom  albom     = this.GetAlbom(albomName, catalog.Alboms);

            if (albom == null)
            {
                Console.WriteLine($"Can not find Albom with name {albomName}");
                return;
            }
            Console.Write("Enter New Song name: ");
            string songName = Console.ReadLine();

            if (songName == String.Empty)
            {
                songName = ("(unknown_song" +
                            "" + this.unknownID++.ToString() + ")");
            }
            var newSong = new Song(songName);

            Console.Write("Enter Song year: ");
            string songYear = Console.ReadLine();

            if (songYear == String.Empty)
            {
                songYear = ("(empty)");
            }
            newSong.LinkToArtist = albom.Autrhor;
            newSong.Year         = songYear;
            albom.songs.Add(newSong);
        }
Beispiel #5
0
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Albom albom = db.Albom.Find(id);

            if (albom == null)
            {
                return(HttpNotFound());
            }
            return(View(albom));
        }
Beispiel #6
0
        // GET: Alboms/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Albom albom = db.Albom.Find(id);

            if (albom == null)
            {
                return(HttpNotFound());
            }
            //IEnumerable<Compositions_in_album> sostav = db.Compositions_in_album.Where(p => p.ID_Albom == id);
            return(View(albom));
        }
Beispiel #7
0
        private Albom GetAlbom(string albomName, List <Albom> alboms)
        {
            if (alboms.Count == 0)
            {
                return(null);
            }
            Albom albom = null;

            foreach (var item in alboms)
            {
                if (item.Name == albomName)
                {
                    albom = item;
                }
            }
            return(albom);
        }
Beispiel #8
0
        private void AddNewAlbomToCatalog()
        {
            Console.Write("Catalogs:");
            foreach (var cata in this.Catalogs)
            {
                Console.Write($" {cata.Name},");
            }
            Console.Write("\nEnter name of Catalog in which you what to add new Almob: ");
            string  catalogName = Console.ReadLine();
            Catalog catalog     = this.GetCatalog(catalogName);

            if (catalog == null)
            {
                Console.WriteLine($"Can not find Catalog with name {catalogName}");
                return;
            }
            Console.Write("Artist: ");
            foreach (var artst in this.Artists)
            {
                Console.Write($"{artst.Name}, ");
            }
            Console.Write("\nEnter name of Actist: ");
            string artistName = Console.ReadLine();
            Artist artist     = this.GetArtist(artistName);

            if (artist == null)
            {
                Console.WriteLine($"Can not find Artist with name {artistName}");
                return;
            }
            Console.Write("Enter New Albom name: ");
            string albomName = Console.ReadLine();

            if (albomName == String.Empty)
            {
                albomName = ("(unknown_albom" + this.unknownID++.ToString() + ")");
            }
            var newAlbom = new Albom(albomName);

            newAlbom.Autrhor = artist;
            catalog.Alboms.Add(newAlbom);
        }
Beispiel #9
0
        private void AddNewSongToCollection()
        {
            Console.Write("Collections: ");
            foreach (var item in this.Collections)
            {
                Console.Write($"{item.Name}, ");
            }
            Console.Write("\nEnter name of Collection in which you what to add song: ");
            string     collectionName = Console.ReadLine();
            Collection collection     = this.GetCollection(collectionName);

            if (collection == null)
            {
                Console.WriteLine($"Can not find Collection with name {collectionName}");
                return;
            }
            Console.Write("Alboms: ");
            foreach (var catalog1 in this.Catalogs)
            {
                foreach (var albom1 in catalog1.Alboms)
                {
                    Console.Write($"{albom1.Name}, ");
                }
            }
            Console.Write("\nEnter name of Albom which contains song you want to add: ");
            string albomName = Console.ReadLine();
            Albom  albom     = null;

            foreach (var catalog in this.Catalogs)
            {
                albom = this.GetAlbom(albomName, catalog.Alboms);
                if (albom != null)
                {
                    break;
                }
            }
            if (albom == null)
            {
                Console.WriteLine($"Can not find Albom with name {albomName}");
                return;
            }
            Console.Write($"Songs in {albom.Name}: ");
            foreach (var ssong in albom.songs)
            {
                Console.Write($"{ssong.Name}, ");
            }
            Console.WriteLine("\nEnter name of new song you want to add: ");
            string songName = Console.ReadLine();
            Song   song     = null;

            foreach (var tsong in albom.songs)
            {
                if (tsong.Name == songName)
                {
                    song = tsong;
                }
            }
            if (song == null)
            {
                Console.WriteLine($"Song {songName} was not found.");
                return;
            }
            collection.songs.Add(song);
        }
Beispiel #10
0
        private void Search()
        {
            Console.WriteLine("" +
                              "1. Search for song Genre\n" +
                              "2. Search for Artist\n" +
                              "3. Search for Albom\n" +
                              "4. Search for Collection\n" +
                              "5. Search for song Year");
            char command = Console.ReadKey().KeyChar;

            Console.WriteLine("");
            switch (command)
            {
            case '1':
                searchGenre();
                break;

            case '2':
                searchArtist();
                break;

            case '3':
                Console.Write("Alboms: ");
                foreach (var catalog in this.Catalogs)
                {
                    foreach (var alb in catalog.Alboms)
                    {
                        Console.Write($"{alb.Name}, ");
                    }
                }
                Console.Write($"\nEnter albom name: ");
                string albomName = Console.ReadLine();
                Albom  albom     = null;
                foreach (var catalog in this.Catalogs)
                {
                    albom = this.GetAlbom(albomName, catalog.Alboms);
                    if (albom != null)
                    {
                        break;
                    }
                }
                if (albom == null)
                {
                    Console.WriteLine($"Albom with name {albomName} was not found.\n");
                    return;
                }
                Console.WriteLine($"{albom.Name}:");
                foreach (var song in albom.songs)
                {
                    Console.Write($"{song.Name} by {song.LinkToArtist.Name} year{song.Year}\n");
                }
                break;

            case '4':
                Console.Write($"Collections: ");
                foreach (var collectionT in this.Collections)
                {
                    Console.Write($"{collectionT.Name}, ");
                }
                Console.Write("\nEnter collection: ");
                string colName    = Console.ReadLine();
                var    collection = this.GetCollection(colName);
                if (collection == null)
                {
                    Console.WriteLine($"There is no collection with name {colName}");
                    return;
                }
                foreach (var song in collection.songs)
                {
                    Console.WriteLine($"\t\t{song.Name} by {song.LinkToArtist.Name} year({song.Year}) genre({song.LinkToArtist.AtristGenre})");
                }
                break;

            case '5':
                Console.Write("Enter year: ");
                string year = Console.ReadLine();
                foreach (var catalog in this.Catalogs)
                {
                    foreach (var albm in catalog.Alboms)
                    {
                        foreach (var song in albm.songs)
                        {
                            if (song.Year == year)
                            {
                                Console.WriteLine($"\t\t{song.Name} by {song.LinkToArtist.Name} year({song.Year}) genre({song.LinkToArtist.AtristGenre})");
                            }
                        }
                    }
                }
                break;

            default:
                break;
            }
        }