Exemplo n.º 1
0
 public void GetById(int id, Action <Participant, Exception> callback)
 {
     try
     {
         using (ParticipantsEntities _entities = new ParticipantsEntities())
         {
             var participant = _entities.Participants.Single(p => p.Id == id);
             callback(participant, null);
         }
     }
     catch (Exception e)
     {
         callback(null, e);
     }
 }
Exemplo n.º 2
0
 public void GetAll(Action <IEnumerable <Participant>, Exception> callback)
 {
     try
     {
         using (ParticipantsEntities _entities = new ParticipantsEntities())
         {
             var ps = _entities.Participants;
             callback(ps, null);
         }
     }
     catch (Exception e)
     {
         callback(null, e);
     }
 }
Exemplo n.º 3
0
        public void Update(Participant participant, Action <Exception> callback)
        {
            try
            {
                using (ParticipantsEntities _entities = new ParticipantsEntities())
                {
                    var old = _entities.Participants.Single(item => item.Id == participant.Id);
                    old.FirstName = participant.FirstName;    // Not nice, but demo purpose only... ;-)
                    old.LastName  = participant.LastName;
                    old.Company   = participant.Company;

                    _entities.SaveChanges();

                    callback(null);
                }
            }
            catch (Exception e)
            {
                callback(e);
            }
        }