예제 #1
0
파일: RoadHelper.cs 프로젝트: Jos1k/Roads
        /// <summary>
        /// Creates the new feedback.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="leaveFeedback">The leave feedback.</param>
        public static void CreateNewFeedback(IRoadsService client, RDLeaveFeedbackModel leaveFeedback)
        {
            var valueList = new List<FeedbackValueData>();

            leaveFeedback.RDLeaveFeedbackValues.ForEach(m =>
            {
                int feedbackItemId;
                if (int.TryParse(m.FeedbackItemId, out feedbackItemId))
                {
                    valueList.Add(new FeedbackValueData
                    {
                        FeedbackItemId = feedbackItemId,
                        Value = m.Value
                    });
                }
            });

            var newFeedback = new RouteNodeWithFeedbacksData
            {
                DestinationCityNodeId = leaveFeedback.DestinationCityId,
                OriginCityNodeId = leaveFeedback.OriginCityId,
                SubmitTime = leaveFeedback.SubmitTime,
                UserId = leaveFeedback.UserId,
                FeedbackValues = valueList.ToArray()
            };

            client.CreateFeedback(newFeedback);
        }