public IEnumerable <object> Get(int id) { var modes = firmRepository.Get() .Where(d => d.Id == id) .ToList(); List <object> retList = new List <object>(); foreach (var ripOff in modes) { var firmId = ripOff.Id; var firmCategories = ripOff.FirmCategories; try { foreach (var firmCategory in firmCategories) { var lawCategoryId = firmCategory.lawCategoryId; var lawCategories = lawyerRepository.Get().Where(d => d.Id == lawCategoryId).ToList(); var riplawyers = _riplawyer.Get().Where(d => d.RipOffFirmId == firmId); retList.Add(new { RipOffFirm = ripOff, lawCategories = lawCategories, lawyers = riplawyers }); } } catch (Exception ex) { var result = new { Message = ex.Message, InnerException = ex.InnerException.ToString() }; } } return(retList.AsEnumerable().ToList()); }
public IHttpActionResult Get() { try { IQueryable <RipOffLawyer> lawyer = null; lawyer = _repository.Get(); return(Ok(lawyer .OrderBy(d => d.Id) .ToList())); } catch (Exception ex) { return(InternalServerError()); } }