public static IList <StyleFeatureValueDTO> ExtactFeatureValueList(string description) { var results = new List <StyleFeatureValueDTO>(); if (String.IsNullOrEmpty(description)) { return(results); } var featureNameKey = @"<th class=""a-span5 a-size-base"">"; var featureValueKey = @"<td class=""a-span7 a-size-base"">"; var startIndex = 0; var nextNameIndex = description.IndexOf(featureNameKey, startIndex); var nextValueIndex = description.IndexOf(featureValueKey, startIndex); while (nextNameIndex >= 0) { nextValueIndex += featureValueKey.Length; nextNameIndex += featureNameKey.Length; var endValueIndex = description.IndexOf("</td>", nextValueIndex); var endNameIndex = description.IndexOf("</th>", nextNameIndex); var value = description.Substring(nextValueIndex, endValueIndex - nextValueIndex); var name = StringHelper.AddSpacesBeforeUpperCaseLetters(description.Substring(nextNameIndex, endNameIndex - nextNameIndex)); value = StringHelper.TrimTags(StringHelper.TrimWhitespace(value)); //Replaces value = value.Replace("Base MetalåÊ", "Base Metal") .Replace("Stainless steel, Stainless Steel", "Stainless steel") .Replace("STAINLESS STEEL", "Stainless steel") .Replace("SiliconeåÊ", "Silicone") .Replace("åÊ", ""); if (name.Length < 25 && name.Length > 1) { results.Add(new StyleFeatureValueDTO() { Value = value, FeatureName = name }); } startIndex = Math.Max(endValueIndex, endNameIndex); nextValueIndex = description.IndexOf(featureValueKey, startIndex); nextNameIndex = description.IndexOf(featureNameKey, startIndex); } return(results); }
public StyleChangeViewModel(StyleChangeHistoryDTO change) { ChangedBy = change.ChangedBy; ChangedByName = change.ChangedByName; ChangeDate = change.ChangeDate; ChangeName = StringHelper.AddSpacesBeforeUpperCaseLetters(change.FieldName); if (change.FieldName == StyleHistoryHelper.LocationKey) { ChangeName = "Location " + change.FromValue + " => " + change.ToValue; } if (change.FieldName == StyleHistoryHelper.OnHoldKey && change.ToValue == "True") { ChangeName = "Put on hold"; } if (change.FieldName == StyleHistoryHelper.OnHoldKey && change.ToValue == "False") { ChangeName = "UnHold"; } if (change.FieldName == StyleHistoryHelper.OnHoldKey && change.ToValue == "True") { ChangeName = "Put on system hold"; } if (change.FieldName == StyleHistoryHelper.OnHoldKey && change.ToValue == "False") { ChangeName = "System unhold"; } if (change.FieldName == StyleHistoryHelper.AttachListingKey) { Message = "Marketplace: " + GetMarketName(change.ExtendFromValue) + ", ASIN:" + (change.ExtendToValue ?? "").Split(':').LastOrDefault(); } if (change.FieldName == StyleHistoryHelper.DetachListingKey) { Message = "Marketplace: " + GetMarketName(change.ExtendFromValue) + ", ASIN:" + (change.ExtendToValue ?? "").Split(':').LastOrDefault(); ChangeName = "Listing detached"; } if (change.FieldName == StyleHistoryHelper.CommentKey) { Message = change.ToValue; ChangeName = "Comment changed"; } if (change.FieldName == StyleHistoryHelper.PictureKey) { Value = change.ToValue; ValueUrl = change.ToValue; ChangeName = "Picture changed"; } if (change.FieldName == StyleHistoryHelper.PictureStatusKey) { Message = Enum.Parse(typeof(StylePictureStatuses), change.FromValue).ToString() + " => " + Enum.Parse(typeof(StylePictureStatuses), change.ToValue).ToString(); ChangeName = "Picture status changed"; } }