public OperationResult <List <AdoptionContract> > GetAll() { try { var animals = _animalService.GetAll() .Result .Where(x => x.AdoptedBy != null) .ToList(); var adoptions = new List <AdoptionContract>(); foreach (var item in animals) { adoptions.Add(new AdoptionContract() { Adopter = _adopterService.Get(item.AdoptedBy.Value).Result, Animal = item, }); } return(new OperationResult <List <AdoptionContract> >(true, "Success", adoptions)); } catch (Exception e) { return(new OperationResult <List <AdoptionContract> >(false, e.Message, null)); } }
public JsonResult Get(string adopterID) { var result = _adopterService.Get(Guid.Parse(adopterID)); return(Json(result, JsonRequestBehavior.AllowGet)); }