예제 #1
0
        private void FillReasonsIfItIsNecessary(ReviewTravelFeeling feeling)
        {
            foreach (ReviewTravelFeelingReason reason in feeling.ReviewTravelFeelingReasons)
            {
                if (String.IsNullOrEmpty(reason.Description))
                {
                    TravelFeelingReason existingReason = this._travelFeelingService.GetTravelFeelingReasonById(feeling.FeelingId, reason.ReasonId);

                    reason.Description = existingReason.Description;
                }
            }
        }
예제 #2
0
        public TravelFeelingReason GetTravelFeelingReasonById(int travelFeelingId, int reasonId)
        {
            TravelFeelingReason reason = null;

            IList <TravelFeelingReasonsPerFeelingAndTransportType> relations = this._relationsRepository.GetAllByConditions(x =>
                                                                                                                            x.TravelFeelingId == travelFeelingId && x.TravelFeelingReasonId == reasonId);

            if (relations.Count > 0)
            {
                IList <int> reasonsIds = relations.Select(x => x.TravelFeelingReasonId).ToList();

                reason = this._reasonRepository.GetFirstByConditions(x => reasonsIds.Contains(x.ReasonId));
            }

            if (reason == null)
            {
                throw new ObjectNotFoundException();
            }

            return(reason);
        }