Beispiel #1
0
        /// <summary>
        /// Fills the add road model for step two.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="cities">The cities.</param>
        /// <returns>
        /// The <see cref="AddRoadModelForStepTwo"/> for Add Road Step 2.
        /// </returns>
        public static AddRoadModelForStepTwo FillAddRoadModelForStepTwo(IRoadsService client, List<KeyValuePair<City, City>> cities)
        {
            var addRoadModelForStepTwo = new AddRoadModelForStepTwo();

            client.GetFeedbackControlsListForNewFeedback()
                .ForEach(x => addRoadModelForStepTwo.FeedbackControls.Add(new FeedbackControl()
                {
                    JSCode = x.FeedbackModel.JavascriptCode,
                    HTMLCode = x.FeedbackModel.HtmlCode,
                    SortNumber = x.FeedbackItem.SortNumber,
                    IsMandatory = x.FeedbackItem.Mandatory,
                    DescriptionTranslationKey = x.FeedbackItem.DescriptionTranslationKey,
                    NameTranslationKey = x.FeedbackItem.NameTranslationKey,
                    FeedBackItemId = x.FeedbackItem.FeedbackItemId
                }));

            addRoadModelForStepTwo.FeedbackControls = addRoadModelForStepTwo
                .FeedbackControls
                .OrderBy(x => x.SortNumber).ToList();

            byte fakekId = 0;
            cities.ForEach(x =>
            {
                addRoadModelForStepTwo.Feedbacks.Add(new FeedbackToRouteNode()
            {
                OriginCityName = x.Key.CityName,
                OriginCityNodeId = x.Key.CityId,
                DestinationCityName = x.Value.CityName,
                DestinationCityNodeId = x.Value.CityId,
                FeedbackId = fakekId,
                FeedbackValues = new List<FeedbackValue>()
            });
                fakekId++;
            });

            fakekId = 0;
            addRoadModelForStepTwo.FeedbackControls.
                ForEach(
                    x => addRoadModelForStepTwo.Feedbacks.ForEach(
                        y =>
                        {
                            y.FeedbackValues.Add(new FeedbackValue()
                            {
                                FeedbackItemId = x.FeedBackItemId,
                                FeedbackId = y.FeedbackId,
                                FeedbackValueId = fakekId,
                                Value = string.Empty
                            });
                            fakekId++;
                        }));
            return addRoadModelForStepTwo;
        }
Beispiel #2
0
        /// <summary>
        /// Adds the new feedbacks or route if not exist.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="routeFeedbacksModel">The route feedbacks model.</param>
        public static string AddNewFeedbacksOrRouteIfNotExist(IRoadsService client, AddRoadModelForStepTwo routeFeedbacksModel)
        {
            List<RouteNodeWithFeedbacksData> routeNodeWithFeedbacks = new List<RouteNodeWithFeedbacksData>();

            int userId = client.GetUserIdOrCreateNewIfNotExist(routeFeedbacksModel.UserName, routeFeedbacksModel.UserName, "TestUserRole");

            routeFeedbacksModel.Feedbacks.ForEach(feedback =>
            {
                routeNodeWithFeedbacks.Add(new RouteNodeWithFeedbacksData()
                {
                    DestinationCityNodeId = int.Parse(feedback.DestinationCityNodeId),
                    OriginCityNodeId = int.Parse(feedback.OriginCityNodeId),
                    OriginCityNode = feedback.OriginCityName,
                    DestinationCityNode = feedback.DestinationCityName,
                    SubmitTime = DateTime.Now,
                    UserId = userId,
                    FeedbackValues = feedback.FeedbackValues.Select(feedbackValue => new FeedbackValueData()
                    {
                        FeedbackItemId = feedbackValue.FeedbackItemId.Value,
                        Value = feedbackValue.Value == "undefined" ? "" : feedbackValue.Value
                    }).ToArray()
                });
            });

            return client.AddFeedbacksToNewOrExistingRoutes(routeNodeWithFeedbacks.ToArray());
        }
Beispiel #3
0
 public ActionResult AddRoadStepTwo2(AddRoadModelForStepTwo model)
 {
     string url = RoadHelper.AddNewFeedbacksOrRouteIfNotExist(client, model);
     return RedirectToAction("Datails", new { id = url });
 }