Exemple #1
0
        public IHttpActionResult GetListAdvancedSearch(
            int id        = 0
            , string name = null
            , int?gender  = null
            , System.DateTime?birthDateFrom = null
            , System.DateTime?birthDateTo   = null
            , string occupation             = null
            , string employer              = null
            , string phone                 = null
            , string email                 = null
            , string identityCardNumber    = null
            , int?countryId                = null
            , string friendOrFamilyContact = null
            , int?photo             = null
            , int?addressId         = null
            , bool?hasCar           = null
            , bool?hasDriverLicense = null
            , bool?hasBike          = null
            , string vehicleMake    = null
            , string vehicleModel   = null
            , bool?active           = null
            )
        {
            try
            {
                // advanced search

                log.Debug("GetVolunteerListAdvancedSearch");

                IEnumerable <VolunteerDTO> resultsDTO = _volunteerService.GetVolunteerListAdvancedSearch(
                    name
                    , gender
                    , birthDateFrom
                    , birthDateTo
                    , occupation
                    , employer
                    , phone
                    , email
                    , identityCardNumber
                    , countryId
                    , friendOrFamilyContact
                    , photo
                    , addressId
                    , hasCar
                    , hasDriverLicense
                    , hasBike
                    , vehicleMake
                    , vehicleModel
                    , active
                    );

                // convert to view model list, and add edit url
                List <VolunteerViewModel> volunteerList = resultsDTO.Select(volunteer => new VolunteerViewModel(volunteer, GetEditUrl(volunteer.VolunteerId))).ToList();

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

                //return Content(JsonConvert.SerializeObject(volunteerList), "application/json");
                //return JsonConvert.SerializeObject(volunteerList);
                return(Ok(volunteerList));
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }