public Result <ShowAdvert> GetAdvert(AdType adType, int id, bool admin) { var showAdvert = new ShowAdvert { AdType = adType }; if (adType == AdType.Flat) { var flat = _getAdvertService.GetAdvert <Flat, ShowFlat>(id, admin); if (flat == null) { return(new Result <ShowAdvert>(false, null, "", null)); } var neighbours = _getNextPreviousService.GetNeighbours <Flat, ShowFlat>(id); if (neighbours.Previous != null) { flat.Previous = neighbours.Previous.Number; } if (neighbours.Next != null) { flat.Next = neighbours.Next.Number; } showAdvert.Flat = flat; } else if (adType == AdType.House) { var house = _getAdvertService.GetAdvert <House, ShowHouse>(id, admin); if (house == null) { return(new Result <ShowAdvert>(false, null, "", null)); } var neighbours = _getNextPreviousService.GetNeighbours <House, ShowHouse>(id); if (neighbours.Previous != null) { house.Previous = neighbours.Previous.Number; } if (neighbours.Next != null) { house.Next = neighbours.Next.Number; } showAdvert.House = house; } else if (adType == AdType.Land) { var land = _getAdvertService.GetAdvert <Land, ShowLand>(id, admin); if (land == null) { return(new Result <ShowAdvert>(false, null, "", null)); } var neighbours = _getNextPreviousService.GetNeighbours <Land, ShowLand>(id); if (neighbours.Previous != null) { land.Previous = neighbours.Previous.Number; } if (neighbours.Next != null) { land.Next = neighbours.Next.Number; } showAdvert.Land = land; } return(new Result <ShowAdvert>(true, null, "", showAdvert)); }