예제 #1
0
        public IActionResult GetHouseFlats(string id)
        {
            var flatsInHouseResult = _houseService.GetHouseFlats(id);

            if (!flatsInHouseResult.Status)
            {
                if (flatsInHouseResult.ServerError)
                {
                    return(StatusCode(500));
                }

                if (flatsInHouseResult.ItemNotFound)
                {
                    return(NotFound("House not found."));
                }

                return(BadRequest(new FailedHouseResponse
                {
                    Errors = flatsInHouseResult.Errors,
                    Status = flatsInHouseResult.Status
                }));
            }

            return(Ok(new SuccessHouseFlatsResponse
            {
                Status = flatsInHouseResult.Status,
                Flats = flatsInHouseResult.Flats
            }));
        }