/// <summary> /// Gets the find route details model. /// </summary> /// <param name="client">The client.</param> /// <param name="urlId">The URL identifier.</param> /// <param name="language">The language.</param> /// <returns>Return view model for Find Route Details page.</returns> public static FindRoadDatailsModel GetFindRouteDetailsModel(IRoadsService client, string urlId, string language) { var model = new FindRoadDatailsModel(); string hash = GetHashFromUrl(urlId); var rdControls = new List<FeedbackControl>(); HolisticFeedback[] feedmackModel = client.GetFeedbackControlsListForNewFeedback(); rdControls.AddRange(feedmackModel.Select(holisticFeedback => new FeedbackControl { DescriptionTranslationKey = holisticFeedback.FeedbackItem.DescriptionTranslationKey, SortNumber = holisticFeedback.FeedbackItem.SortNumber, NameTranslationKey = holisticFeedback.FeedbackItem.NameTranslationKey, HTMLCode = holisticFeedback.FeedbackModel.HtmlCode, JSCode = holisticFeedback.FeedbackModel.JavascriptCode, FeedBackItemId = holisticFeedback.FeedbackItem.FeedbackItemId, IsMandatory = holisticFeedback.FeedbackItem.Mandatory })); model.MandatoryControlsId = rdControls.Where(item => item.IsMandatory == true).Select(it => it.FeedBackItemId).ToArray(); RouteDetailsData routeDetails = GetRouteDetails(client, hash, CultureHelper.GetCulture(language)); model.RDNodesData = FillRDNodesData(routeDetails.RouteDetailsItems, rdControls); model.CityPointsNames = FillCityPList(model.RDNodesData); model.RouteSummary = FillRouteSummary(model.RDNodesData); return model; }
/// <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; }