public Opportunity DeleteOpportunity(int opportunityID) { Opportunity dbEntry = context.Opportunities .FirstOrDefault(p => p.OpportunityID == opportunityID); if (dbEntry != null) { context.Opportunities.Remove(dbEntry); context.SaveChanges(); } return(dbEntry); }
public void SaveOpportunity(Opportunity opportunity) { if (opportunity.OpportunityID == 0) { context.Opportunities.Add(opportunity); } else { Opportunity dbEntry = context.Opportunities .FirstOrDefault(p => p.OpportunityID == opportunity.OpportunityID); if (dbEntry != null) { dbEntry.JobTitle = opportunity.JobTitle; dbEntry.Description = opportunity.Description; dbEntry.VolunteerCenter = opportunity.VolunteerCenter; //connects the database to the Edit button so that it saves the edited user input dbEntry.Keyword = opportunity.Keyword; } } context.SaveChanges(); }