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); } }
partial void UpdateMusicGroup(MusicGroup instance);
partial void DeleteMusicGroup(MusicGroup instance);
partial void InsertMusicGroup(MusicGroup instance);