예제 #1
0
        /// <summary>
        /// Get list of Volunteers
        /// </summary>
        /// <returns>json list of Volunteer view models</returns>
        public IHttpActionResult GetList()
        {
            try
            {
                // get list
                List <VolunteerViewModel> volunteers;

                log.Debug("_volunteerService.GetVolunteers");

                // add edit url
                volunteers = _volunteerService.GetVolunteers()
                             .Select(volunteer => new VolunteerViewModel(volunteer, GetEditUrl(volunteer.VolunteerId)))
                             .ToList();

                log.Debug("result: 'success', count: " + (volunteers != null ? volunteers.Count().ToString() : "null"));

                //return Json(volunteers, JsonRequestBehavior.AllowGet);
                //return Content(JsonConvert.SerializeObject(volunteers), "application/json");
                //return JsonConvert.SerializeObject(volunteers);
                return(Ok(volunteers));
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
예제 #2
0
        /// <summary>
        /// Get list of Volunteers
        /// </summary>
        /// <returns>list of Volunteers</returns>
        public VolunteerDataContract[] GetList()
        {
            try
            {
                // get list
                List <VolunteerDataContract> volunteers;

                log.Debug("_volunteerService.GetVolunteers");

                // add edit url
                volunteers = _volunteerService.GetVolunteers()
                             .Select(volunteer => new VolunteerDataContract(volunteer, GetEditUrl(volunteer.VolunteerId)))
                             .ToList();

                log.Debug("result: 'success', count: " + (volunteers != null ? volunteers.Count().ToString() : "null"));

                return(volunteers.ToArray());
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
예제 #3
0
 public IActionResult GetVolunteers()
 {
     return(Ok(_volunteerService.GetVolunteers()));
 }