Esempio n. 1
0
		/// <summary>
		/// Gets the holistic feedback for.
		/// </summary>
		/// <param name="node">The node.</param>
		/// <param name="language"></param>
		/// <returns> The List of <see cref="HolisticFeedback"/>.</returns>
		public List<HolisticFeedback> GetHolisticFeedbackFor( RouteNode node, string language ) {
			var result = new List<HolisticFeedback>();

			var languageObject = DataContext.Languages.FirstOrDefault( k => k.Name.ToLower() == language.ToLower() );

			int languageId = DataContext.Languages.FirstOrDefault( k => k.IsDefault == true ).LanguageId;

			if( languageObject != null ) {
				languageId = languageObject.LanguageId;
			}

			var feedbacks = DataContext.Feedbacks.Where( e => e.RouteNodeId == node.RouteNodeId ).ToList();

			var destinationCityName = DataContext.MapObjectTranslations.SingleOrDefault(
				m => m.LanguageKey == node.DestinationCityNode.LanguageKey && m.LanguageId == languageId );

			var originCityName = DataContext.MapObjectTranslations.SingleOrDefault(
				m => m.LanguageKey == node.OriginCityNode.LanguageKey && m.LanguageId == languageId );

			foreach( var feedback in feedbacks ) {
				feedback.User = DataContext.Users.SingleOrDefault( m => m.UserId == feedback.UserId );
				var holisticFeedback = new HolisticFeedback {
					UserId = feedback.UserId,
					UserName = feedback.User.Name,
					FeedbackId = feedback.FeedbackId,
					SubmitTime = feedback.SubmitTime,
					OriginCityName = originCityName != null ? originCityName.Value : String.Empty,
					DestinationCityName = destinationCityName != null ? destinationCityName.Value : String.Empty
				};

				var feedbackValue = DataContext.FeedbackValues.FirstOrDefault( f => f.FeedbackId == feedback.FeedbackId );

				if( feedbackValue != null ) {
					holisticFeedback.Value = feedbackValue.Value;

					var feedbackItem =
						DataContext.FeedbackItems.FirstOrDefault( f => f.FeedbackItemId == feedbackValue.FeedbackItemId );
					if( feedbackItem != null ) {

						holisticFeedback.FeedbackItem = new FeedbackItemData {
							DescriptionTranslationKey = feedbackItem.DescriptionTranslationKey,
							FeedbackItemId = feedbackItem.FeedbackItemId,
							FeedbackModelId = feedbackItem.FeedbackModelId,
							IsNumeric = feedbackItem.IsNumeric,
							NameTranslationKey = feedbackItem.NameTranslationKey,
							Mandatory = feedbackItem.Mandatory,
							SortNumber = feedbackItem.SortNumber
						};
					}
				}

				result.Add( holisticFeedback );
			}

			return result;
		}
Esempio n. 2
0
        /// <summary>
        /// Gets the feedback controls for new feedback.
        /// </summary>
        /// <returns>GetLanguageById list of feedback controls for new feedback</returns>
        public List<HolisticFeedback> GetFeedbackControlsForNewFeedback()
        {
            var feebackControls = new List<HolisticFeedback>();

            foreach (FeedbackItem feedbackItem in _routeRepository.GetFeedbackControlsForNewFeedback())
            {
                var feedbackControlItem = new HolisticFeedback();

                feedbackControlItem.Value = null;
                feedbackControlItem.UserName = String.Empty;
                feedbackControlItem.FeedbackItem = new FeedbackItemData()
                {
                    FeedbackItemId = feedbackItem.FeedbackItemId,
                    IsNumeric = feedbackItem.IsNumeric,
                    Mandatory = feedbackItem.Mandatory,
                    SortNumber = feedbackItem.SortNumber,
                    FeedbackModelId = feedbackItem.FeedbackModelId,
                    DescriptionTranslationKey = feedbackItem.DescriptionTranslationKey,
                    NameTranslationKey = feedbackItem.NameTranslationKey
                };
                feedbackControlItem.FeedbackModel = new FeedbackModelData()
                {
                    FeedbackModelId = feedbackItem.FeedbackModel.FeedbackModelId,
                    HtmlCode = feedbackItem.FeedbackModel.HtmlCode,
                    JavascriptCode = feedbackItem.FeedbackModel.JavascriptCode
                };
                feebackControls.Add(feedbackControlItem);
            }
            return feebackControls;
        }