public static void AddOrUpdate(Playlist playlist) { using (var dbContext = new AudioPlayerDbContext()) { dbContext.Playlists.AddOrUpdate(playlist); dbContext.SaveChanges(); } }
public static void AddOrUpdate(MusicTrack musicTrack) { using (var dbContext = new AudioPlayerDbContext()) { dbContext.MusicTracks.AddOrUpdate(musicTrack); dbContext.SaveChanges(); } }
public static void Delete(Playlist playlist) { using (var dbContext = new AudioPlayerDbContext()) { //dbContext.Entry(playlist).State = EntityState.Deleted; dbContext.Playlists.Remove(playlist); dbContext.SaveChanges(); } }
private void signInBtn_Click(object sender, EventArgs e) { if (FullNameTxtBox.Text == string.Empty) { FullNameTxtBox.BackColor = Color.IndianRed; return; } if (LoginTxtBox.Text == string.Empty) { LoginTxtBox.BackColor = Color.IndianRed; return; } if (PasswordTxtBox.Text == string.Empty || ConfirmPasswordTxtBox.Text == string.Empty || PasswordTxtBox.Text != ConfirmPasswordTxtBox.Text) { PasswordTxtBox.BackColor = Color.IndianRed; ConfirmPasswordTxtBox.BackColor = Color.IndianRed; return; } using (var dbContext = new AudioPlayerDbContext()) { _user.UserFullName = FullNameTxtBox.Text; _user.UserLogin = LoginTxtBox.Text; if (_user.PasswordHash != PasswordTxtBox.Text) { _user.PasswordHash = AuthUtils.GetHash(PasswordTxtBox.Text); } dbContext.Users.AddOrUpdate(_user); dbContext.SaveChanges(); } DialogResult = DialogResult.OK; Close(); }