public void TestGetCommunityById() { var context = TestUtils.GetDbContext(); SectionService sectionService = TestUtils.CreateService <SectionService>(context); sectionService.GetByComunityId(new Guid("f42c48cf-c90f-4d71-a501-b88c4165efee")); }
public ActionResult Get(Guid id) { try { var serviceResponse = _communityService.GetCombinedById(id); if (serviceResponse.IsError()) { return(new ObjectNotFoundResult(serviceResponse)); } Community community = serviceResponse.GetData <Community>(); Location location = community.Location; ApiResponse apiResponse = this._locationService .GetChildLocations(location.CountryId.Value, location.StateId.Value, location.CityId.Value, community.AreaId); LocationElemensDto locationElementsDto = apiResponse.GetData <LocationElemensDto>(); apiResponse = _sectionService.GetByComunityId(id); var sections = apiResponse.GetData <List <Section> >(); CommunityApiModel communityApiModel = _communityMapper.MapGet(community, locationElementsDto, sections); return(new ObjectFoundResult(new ApiResponse(communityApiModel))); } catch (Exception ex) { return(new UnknownErrorResult(ex, base._errorEnabled)); } }
public ActionResult GetByCommunitId(Guid communityId) { try { var apiResponse = _sectionService.GetByComunityId(communityId); var sectionsList = apiResponse.GetData <List <Section> >(); var sectionApiList = new List <SectionApiModel>(); SectionMapper.MapToApiModel(sectionsList, sectionApiList); return(Ok(sectionApiList)); } catch (Exception ex) { return(new UnknownErrorResult(ex, base._errorEnabled)); } }