public GetPetResponse GetPets(GetPetRequest request) { var response = new GetPetResponse() { Pets = new List <PetResponse>() }; if (_volunteerDbContext.Volunteers.Where(v => v.IdVolunteer == request.IdVolunteer).Count() != 1) { throw new Exception(); } _volunteerDbContext.Join(_volunteerDbContext.Volunteer_Pets, vol => vol.IdVolunteer, vol_pet => vol_pet.IdVolunteer, (vol, vol_pet) => new { vol.IdVolunteer, vol_pet.IdPet }); return(response); }
public IActionResult GetPets(int id, int year) { var request = new GetPetRequest() { IdVolunteer = id, Year = year }; try { return(Ok(_dbService.GetPets(request))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }