Ejemplo n.º 1
0
        public async Task <BaseResult <List <HotelFacilityGroupViewModel> > > GetTemplateHotelFacilityFields(int templateId, int languageId)
        {
            DynamicParameters paramCollection = ContractTemplateRequestMapper.CreateTemplateHotelFacilityRequestParams(templateId, languageId, true);
            //return await iTemplateHotelFieldLibrary.ExecuteStoredProcedure(Constants.StoredProcedure.GetHotelFieldsByTemplateId, paramCollection).ConfigureAwait(false);
            var facilityGroup = await iTemplateHotelFieldLibrary.ExecuteStoredProcedure(Constants.StoredProcedure.GetHotelFieldsByTemplateId, paramCollection).ConfigureAwait(false);

            //IConnection<HotelFacilityGroup> iHotelFacilityGroupLibrary,
            //                        IConnection< HotelFacilityType > iHotelFacilityTypeLibrary,
            //                        IConnection<HotelFacility> iHotelFacilityLibrary,
            //                        IConnection< HotelFacilityRelation > iHotelFacilityRelationLibrary,
            //                        IConnection<InOutTime> inOutTimeLibrary


            IFacilities iFacilities = new FacilitiesRepository(new DapperConnection <HotelFacilityGroup>(iConfiguration), new DapperConnection <HotelFacilityType>(iConfiguration), new DapperConnection <HotelFacility>(iConfiguration), null, null);
            BaseResult <List <HotelFacilityGroup> > hotelFacilityGroup = await iFacilities.GeHotelFacilityGroup().ConfigureAwait(false);

            BaseResult <List <HotelFacilityType> > hotelFacilityType = await iFacilities.GeHotelFacilityType().ConfigureAwait(false);

            BaseResult <List <HotelFacility> > hotelFacility = await iFacilities.GeHotelFacility().ConfigureAwait(false);

            var facilities = FacilitiesResponseMapper.MapHotelFacilities(hotelFacility);                             ////maps to facilityViewModel
            var result     = FacilitiesResponseMapper.MapHotelFacilityType(facilities, hotelFacilityType);           ////maps to HotelFacilityTypeViewModel
            var result1    = FacilitiesResponseMapper.MapHotelFacilityGroup(facilities, hotelFacilityGroup, result); ////Maps to HotelFacilityGroupViewModel

            ContractTemplateResponseMapper.MapToFacilityFieldToViewModel(facilityGroup.Result, result1.Result);

            return(result1);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetHotelFacilityGroups([FromBody] int hotelId)
        {
            BaseResult <List <HotelFacilityGroupViewModel> > hotelFacilityGroupResult = new BaseResult <List <HotelFacilityGroupViewModel> >
            {
                Result = RedisCacheHelper.Instance.Get <List <HotelFacilityGroupViewModel> >(Constants.CacheKeys.HotelFacilityGroupList)
            };

            if (hotelId < 1)
            {
                hotelFacilityGroupResult.IsError = true;
                hotelFacilityGroupResult.Message = Core.Model.Helper.Constants.ErrorMessage.InvalidId;
                return(this.BadRequest(hotelFacilityGroupResult));
            }
            BaseResult <List <HotelFacilityRelation> > facilitiesSelected = await this.iFacilities.GetSelectedFacilities(hotelId).ConfigureAwait(false);

            if (hotelFacilityGroupResult.Result == null || hotelFacilityGroupResult.Result.Count == 0)
            {
                BaseResult <List <HotelFacilityGroup> > hotelFacilityGroup = await this.iFacilities.GeHotelFacilityGroup().ConfigureAwait(false);

                BaseResult <List <HotelFacilityType> > hotelFacilityType = await this.iFacilities.GeHotelFacilityType().ConfigureAwait(false);

                BaseResult <List <HotelFacility> > hotelFacility = await this.iFacilities.GeHotelFacility().ConfigureAwait(false);

                if ((hotelFacilityGroup.IsError && hotelFacilityGroup.ExceptionMessage != null) || (hotelFacilityType.IsError && hotelFacilityType.ExceptionMessage != null) || (hotelFacility.IsError && hotelFacility.ExceptionMessage != null))
                {
                    return(new StatusCodeResult(500));
                }
                else if (hotelFacilityGroup.Result == null || hotelFacilityGroup.Result.Count == 0 || hotelFacilityType.Result == null || hotelFacilityType.Result.Count == 0 || hotelFacility.Result == null || hotelFacility.Result.Count == 0)
                {
                    return(this.NoContent()); ////204
                }
                else
                {
                    var facilities = FacilitiesResponseMapper.MapHotelFacilities(hotelFacility);                             ////maps to facilityViewModel
                    var result     = FacilitiesResponseMapper.MapHotelFacilityType(facilities, hotelFacilityType);           ////maps to HotelFacilityTypeViewModel
                    var result1    = FacilitiesResponseMapper.MapHotelFacilityGroup(facilities, hotelFacilityGroup, result); ////Maps to HotelFacilityGroupViewModel
                    RedisCacheHelper.Instance.Set <List <HotelFacilityGroupViewModel> >(Constants.CacheKeys.HotelFacilityGroupList, result1.Result);
                    var mappedFacility = FacilitiesResponseMapper.MapSelectedHotelFacilities(result1, facilitiesSelected);
                    return(this.Ok(mappedFacility));
                }
            }

            if (facilitiesSelected.Result == null || facilitiesSelected.Result.Count == 0)
            {
                return(this.Ok(hotelFacilityGroupResult));
            }
            else
            {
                var mappedFacilities = FacilitiesResponseMapper.MapSelectedHotelFacilities(hotelFacilityGroupResult, facilitiesSelected);
                return(this.Ok(mappedFacilities)); ////200
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetContractFacilityGroups([FromBody] int contractId)
        {
            BaseResult <List <HotelFacilityGroupViewModel> > hotelFacilityGroupResult = new BaseResult <List <HotelFacilityGroupViewModel> >
            {
                Result = RedisCacheHelper.Instance.Get <List <HotelFacilityGroupViewModel> >(Constants.CacheKeys.HotelFacilityGroupList)
            };

            if (contractId < 1)
            {
                hotelFacilityGroupResult.IsError = true;
                hotelFacilityGroupResult.Message = Constants.BadRequestErrorMessage.InvalidContractId;
                return(this.BadRequest(hotelFacilityGroupResult));
            }
            var facilitiesSelected = await this.iFacilities.GetSelectedContractFacilities(contractId).ConfigureAwait(false);

            var contractFacilityGroupList = await this.iFacilities.GetFacilityGroupsForContract(contractId, base.LanguageId).ConfigureAwait(false);

            if ((facilitiesSelected.IsError && facilitiesSelected.ExceptionMessage != null) || (contractFacilityGroupList.IsError && contractFacilityGroupList.ExceptionMessage != null) || !contractFacilityGroupList.Result.Any() || contractFacilityGroupList.Result == null)
            {
                return(StatusCode(500));
            }
            if (hotelFacilityGroupResult.Result == null || !hotelFacilityGroupResult.Result.Any())
            {
                BaseResult <List <HotelFacilityGroup> > hotelFacilityGroup = await this.iFacilities.GeHotelFacilityGroup().ConfigureAwait(false);

                BaseResult <List <HotelFacilityType> > hotelFacilityType = await this.iFacilities.GeHotelFacilityType().ConfigureAwait(false);

                BaseResult <List <HotelFacility> > hotelFacility = await this.iFacilities.GeHotelFacility().ConfigureAwait(false);

                if ((hotelFacilityGroup.IsError && hotelFacilityGroup.ExceptionMessage != null) || (hotelFacilityType.IsError && hotelFacilityType.ExceptionMessage != null) || (hotelFacility.IsError && hotelFacility.ExceptionMessage != null))
                {
                    return(StatusCode(500));
                }
                else if (hotelFacilityGroup.Result == null || !hotelFacilityGroup.Result.Any() || hotelFacilityType.Result == null || !hotelFacilityType.Result.Any() || hotelFacility.Result == null || !hotelFacility.Result.Any())
                {
                    return(this.NoContent()); ////204
                }
                else
                {
                    var facilities = FacilitiesResponseMapper.MapHotelFacilities(hotelFacility);                                       ////maps to facilityViewModel
                    var result     = FacilitiesResponseMapper.MapHotelFacilityType(facilities, hotelFacilityType);                     ////maps to HotelFacilityTypeViewModel
                    hotelFacilityGroupResult = FacilitiesResponseMapper.MapHotelFacilityGroup(facilities, hotelFacilityGroup, result); ////Maps to HotelFacilityGroupViewModel
                    RedisCacheHelper.Instance.Set <List <HotelFacilityGroupViewModel> >(Constants.CacheKeys.HotelFacilityGroupList, hotelFacilityGroupResult.Result);
                }
            }
            var mappedFacility = FacilitiesResponseMapper.MapSelectedContractFacilities(hotelFacilityGroupResult, facilitiesSelected, contractFacilityGroupList.Result);

            return(this.Ok(mappedFacility)); ////200
        }