Пример #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);
            }
        }
Пример #2
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);
            }
        }