Ejemplo n.º 1
0
        public async Task <IActionResult> GetContractHotelDetailsByContractId([FromBody] int contractId)
        {
            BaseResult <ContractHotelDetailsViewModel> contractHotelDetailsResult = new BaseResult <ContractHotelDetailsViewModel>();
            ContractHotelDetailsViewModel result = new ContractHotelDetailsViewModel();

            if (contractId <= default(int))
            {
                contractHotelDetailsResult.IsError = true;
                contractHotelDetailsResult.Message = string.Format(coreHelper.Constants.ErrorMessage.InvalidId, contractId);
                return(BadRequest(contractHotelDetailsResult));
            }
            var contractHotelDetails = await this.contracts.GetContractHotelDetailsByContractId(contractId, base.LanguageId).ConfigureAwait(false);

            if (contractHotelDetails.IsError && contractHotelDetails.ExceptionMessage != null)
            {
                return(new StatusCodeResult(500));
            }
            else if (contractHotelDetails.Result == null || !contractHotelDetails.Result.Any())
            {
                return(new NoContentResult());
            }
            result.ContractHotelDetailsModel = HotelManagementResponseMapper.MapHotelDetailsToHotelDetailsViewModel(contractHotelDetails);

            var contractHotelFields = await this.contracts.GetHotelFieldsForContract(contractId, base.LanguageId).ConfigureAwait(false);

            if (contractHotelFields.IsError && contractHotelFields.ExceptionMessage != null)
            {
                return(new StatusCodeResult(500));
            }
            else if (contractHotelFields.Result == null || !contractHotelFields.Result.Any())
            {
                return(new NoContentResult());
            }
            result.ContractHotelFieldsList.AddRange(ContractsResponseMapper.MapContractHotelFields(contractHotelFields.Result).Result);
            contractHotelDetailsResult.Result = result;
            return(Ok(contractHotelDetailsResult));
        }