private void bunifuThinButton21_Click(object sender, EventArgs e) { try { _user.Projects2.Remove(_user.Projects2.ToList()[listBox1.SelectedIndex]); TeamBuildingEntities.SaveChanges(); LoadProjects(_user); } catch (Exception) { MessageBox.Show("Choose a project"); } }
private void Like_project(object sender, EventArgs e) { BunifuImageButton button = sender as BunifuImageButton; List <LikedProjects> lpr = TeamBuildingEntities.LikedProjects.ToList(); if (!lpr.Where(b => b.LkdUserId == Connection.Current.UsrId && b.LkdPrjtId == (int)button.Tag).Any()) { button.Image = LikedProject.Image; Liked = true; try { TeamBuildingEntities.LikedProjects.Add(new LikedProjects() { LkdPrjtId = (int)button.Tag, LkdUserId = Connection.Current.UsrId }); TeamBuildingEntities.SaveChanges(); } catch (Exception exception) { Console.WriteLine(exception); throw; } } else { button.Image = NotLikedProject.Image; Liked = false; try { TeamBuildingEntities.LikedProjects.Remove(lpr.Where(b => b.LkdUserId == Connection.Current.UsrId && b.LkdPrjtId == (int)button.Tag).First()); TeamBuildingEntities.SaveChanges(); } catch (Exception exception) { Console.WriteLine(exception); throw; } } }