Exemplo n.º 1
0
        public int CreateVolunteer(IVolunteer volunteerDTO)
        {
            Volunteer v = VolunteerFactory.CreateVolunteer(volunteerDTO);

            v = _store.Volunteers.Add(v);
            _store.SaveChanges();
            return(v.Id);
        }
Exemplo n.º 2
0
        public IEnumerable <IVolunteer> GetAllVolunteers()
        {
            IEnumerable <Volunteer> v = _store.Volunteers
                                        .Include(e => e.User)
                                        .ToList();

            return(v.Select(e => VolunteerFactory.CreateVolunteer(e)));
        }
Exemplo n.º 3
0
 public IVolunteer GetVolunteerById(int id)
 {
     try
     {
         Volunteer volunteer = _store.Volunteers
                               .Include(e => e.User)
                               .Single(v => v.Id == id);
         return(VolunteerFactory.CreateVolunteer(volunteer));
     }
     catch (InvalidOperationException) {
         return(null);
     }
 }