コード例 #1
0
        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);
        }
コード例 #2
0
 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();
 }