示例#1
0
        public Participation DeleteParticipatedEvent(int participatedEventID)
        {
            Participation dbEntry = context.Participations.Where(p => p.ID == participatedEventID)
                                    .FirstOrDefault();

            if (dbEntry != null)
            {
                context.Participations.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
示例#2
0
 public void SaveEvent(Participation participation)
 {
     //throw new NotImplementedException();
     if (participation.ID == 0 && participation != null)
     {
         context.Participations.Add(participation);
     }
     else
     {
         Participation dbEntry = context.Participations
                                 .Where(p => p.ID == participation.ID)
                                 .FirstOrDefault();
         if (dbEntry != null)
         {
             dbEntry.StudentNumber  = participation.StudentNumber;
             dbEntry.Title          = participation.Title;
             dbEntry.Username       = participation.Username;
             dbEntry.CreatedEventID = participation.CreatedEventID;
             dbEntry.Date           = participation.Date;
             dbEntry.Location       = participation.Location;
         }
     }
     context.SaveChanges();
 }