Ejemplo n.º 1
0
        public int Save()
        {
            try
            {
                Console.Clear();
                if (SourceManagerSave.AlbumExists(this))
                {
                    throw new Exception("Album exist in Base");
                }

                int ID = SourceManagerSave.Add(this);
                if (ID == -1)
                {
                    throw new Exception("Error, Data didn't save to Base");
                }

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"zapisano {Title} do Bazy Danych pod ID: {ID}");
                Console.ResetColor();
                return(ID);
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ResetColor();
                return(-1);
            }
        }
Ejemplo n.º 2
0
        public static List <QueryModel> CreateQueryList(List <AlbumModel> albumList)
        {
            List <QueryModel> queryList = new List <QueryModel>();

            foreach (AlbumModel album in albumList)
            {
                QueryModel query = new QueryModel();
                query.ExistInDB = SourceManagerSave.AlbumExists(album);
                if (query.ExistInDB)
                {
                    SqlHelper.GetIDByNameAndTitle(album.Artists, album.Title);
                }
                if (!(album.Title is null))
                {
                    query.Title = album.Title;
                }
                if (!(album.Artists is null))
                {
                    query.Artist = album.Artists;
                }
                if (album.ExtraArtists.Count > 0)
                {
                    query.Extraartists = album.ExtraArtists.Count;
                }
                if (album.Genres.Count > 0)
                {
                    query.Genres = String.Join(", ", album.Genres.ToArray());
                }
                if (album.Styles.Count > 0)
                {
                    query.Styles = String.Join(", ", album.Styles.ToArray());
                }
                if (album.TrackList.Count > 0)
                {
                    query.Tracks = album.TrackList.Count;
                }
                if (album.Videos.Count > 0)
                {
                    query.Videos = album.Videos.Count;
                }
                if (album.Images.Count > 0)
                {
                    query.Images = album.Images.Count;
                }
                queryList.Add(query);
            }
            return(queryList);
        }
Ejemplo n.º 3
0
        public int Save()
        {
            try
            {
                if (SourceManagerSave.AlbumExists(this))
                {
                    throw new Exception("Album exist in Base");
                }

                int ID = SourceManagerSave.Add(this);
                if (ID == -1)
                {
                    throw new Exception("Error, Data didn't save to Base");
                }

                return(ID);
            }
            catch (Exception e)
            {
                return(-1);
            }
        }