Ejemplo n.º 1
0
        public System.Guid AddMusicGroup(MusicGroupsFolder.MusicGroup group)  // Pridani hudebni skupiny bez referenci
        {
            var alreadyInDatabase = _database.MusicGroups.FirstOrDefault(stored => stored.MusicGroupID == group.ID);

            if (alreadyInDatabase == null)
            {
                MusicGroup tmpMusicGroup = new MusicGroup()
                {
                    MusicGroupName        = group.Name,
                    MusicGroupCreatedDate = group.CreatedDate,
                    MusicGroupEndDate     = group.EndDate,
                    MusicGroupNationality = group.Nationality,
                    MusicGroupType        = group.Type.ToString(),
                    MusicGroupPhoto       = group.Image
                };
                try
                {
                    _database.MusicGroups.InsertOnSubmit(tmpMusicGroup);
                    _database.SubmitChanges();
                }
                catch (Exception e)
                {
                    ErrorString = e.Message;
                    MessageBox.Show("Nepodařilo se přidat hudební skupinu do databáze!\n\n" + ErrorString);
                }
                return(tmpMusicGroup.MusicGroupID);
            }
            else
            {
                alreadyInDatabase.MusicGroupEndDate     = group.EndDate;
                alreadyInDatabase.MusicGroupCreatedDate = group.CreatedDate;
                alreadyInDatabase.MusicGroupName        = group.Name;
                alreadyInDatabase.MusicGroupNationality = group.Nationality;
                alreadyInDatabase.MusicGroupPhoto       = group.Image;
                alreadyInDatabase.MusicGroupType        = group.Type.ToString();
                _database.MusicGroups.Context.SubmitChanges();
                return(alreadyInDatabase.MusicGroupID);
            }
        }
Ejemplo n.º 2
0
 partial void UpdateMusicGroup(MusicGroup instance);
Ejemplo n.º 3
0
 partial void DeleteMusicGroup(MusicGroup instance);
Ejemplo n.º 4
0
 partial void InsertMusicGroup(MusicGroup instance);