public ActionResult AjaxSelection() { var model = new AjaxSelectionViewModel(); model.OccupationLevel1 = AdwService.GetListCodes("AZ1").ToSelectList(m => m.Code, m => m.Description); return(View(model)); }
public ActionResult MultiSelects() { var model = new MultiSelectsViewModel(); model.Ages = AdwService.GetListCodes("AGE").ToMultiSelectList(m => m.Code, m => m.Description); model.Checkboxes = AdwService.GetListCodes("AGE").ToMultiSelectList(m => m.Code, m => m.Description); model.States = AdwService.GetListCodes("STT").ToSelectListItem(m => m.Code, m => m.Description); return(View(model)); }
public void AdwServiceConstructor_ExpectedException1() { IClient client = new Mock <IClient>().Object; IRuntimeCacheService cacheService = new Mock <IRuntimeCacheService>().Object; IUserService userService = new Mock <IUserService>().Object; ISqlService sql = new Mock <ISqlService>().Object; var target = new AdwService(sql, null, client, cacheService); Assert.Fail("Expected Exception"); }
public ActionResult RelatedCode(string text, int page, string code, string dependentValue, bool dominant, AdwOrderType orderType, AdwDisplayType displayType, IEnumerable <string> excludeValues) { var result = Enumerable.Empty <SelectListItem>(); if (!string.IsNullOrEmpty(code)) { result = AdwService.GetRelatedCodes(code, dependentValue, dominant).ToOrderedSelectListItem(orderType, displayType).Where(m => excludeValues == null || !excludeValues.Contains(m.Value)); } return(AjaxSelectionView(text, page, result)); }
public ActionResult SingleSelects() { var model = new SingleSelectsViewModel(); // SelectList model.Age = AdwService.GetListCodes("AGE").ToSelectList(m => m.Code, m => m.Description); // Enumerable<SelectListItem> model.State = AdwService.GetListCodes("STT").ToSelectListItem(m => m.Code, m => m.Description); return(View(model)); }
/// <summary> /// Returns a single Adw code as a <see cref="IEnumerable{SelectListItem}" />. /// </summary> /// <remarks> /// Not ready for use. /// </remarks> /// <param name="container">The model this object is contained within.</param> /// <param name="selectedCode">The code value that is selected.</param> /// <returns>A <see cref="IEnumerable{SelectListItem}" /> with a single item.</returns> public IEnumerable <SelectListItem> GetSelectListItem(object container, string selectedCode) { #if DEBUG var step = MiniProfiler.Current.Step(string.Format("AdwSelection.GetSelectListItem ({0})", Code)); try { #endif if (string.IsNullOrEmpty(selectedCode)) { return(Enumerable.Empty <SelectListItem>()); } if (AdwType == AdwType.RelatedCode) { RelatedCodeModel relatedCode; if (!string.IsNullOrEmpty(DependentProperty)) { var dependentPropertyValue = HandleEnumerableSelectListItem(GetDependentPropertyValue(container)); if (dependentPropertyValue == null || string.IsNullOrEmpty(dependentPropertyValue.ToString())) { return(Enumerable.Empty <SelectListItem>()); } relatedCode = AdwService.GetRelatedCode(Code, dependentPropertyValue.ToString(), selectedCode, Dominant, CurrentCodesOnly); } else { relatedCode = AdwService.GetRelatedCode(Code, DependentValue, selectedCode, Dominant, CurrentCodesOnly); } return(relatedCode != null ? new[] { relatedCode }.ToOrderedSelectListItem(OrderType, DisplayType, relatedCode.Dominant ? relatedCode.SubordinateCode : relatedCode.DominantCode).Where(m => ExcludeValues == null || !ExcludeValues.Contains(m.Value)) : Enumerable.Empty <SelectListItem>()); } var listCode = AdwService.GetListCode(Code, selectedCode, CurrentCodesOnly); return(listCode != null ? new[] { listCode }.ToOrderedSelectListItem(OrderType, DisplayType, listCode.Code).Where(m => ExcludeValues == null || !ExcludeValues.Contains(m.Value)) : Enumerable.Empty <SelectListItem>()); #if DEBUG } finally { if (step != null) { step.Dispose(); } } #endif }
/// <summary> /// Validates that the text does not contain any blue words. /// </summary> /// <param name="displayName">The display name of the property to include in the error message.</param> /// <param name="text">The text to validate for blue words.</param> /// <returns>The validation result of success if no blue words were found; otherwise, a validation result with an error message.</returns> internal ValidationResult ValidateBlueWord(string displayName, string text) { if (!string.IsNullOrEmpty(text)) { var blueWords = new List <string>(); // Get unacceptable words var unacceptableWords = AdwService.GetRelatedCodes("OFTW", "UNA").ToCodeModelList().Select(a => Regex.Escape(a.Description)).ToList(); // Get identified words that contain unacceptable words but are identified as being allowed var identifiedWords = AdwService.GetRelatedCodes("OFTW", "IDE").ToCodeModelList().Select(a => Regex.Escape(a.Description)).ToList(); // Build word boundary pattern to match against identified words (the full word must match) var identifiedWordsPattern = string.Format(@"\b({0})\b", string.Join("|", identifiedWords)); // Remove identified words from text so we can ignore them as they are allowed text = Regex.Replace(text, identifiedWordsPattern, " ", (RegexOptions.IgnoreCase | RegexOptions.Singleline)); // Build word boundary pattern to match against unacceptable words (any words containing an unacceptable word will be matched) var unacceptableWordsPattern = string.Format("({0})", string.Join("|", unacceptableWords)); // Get unacceptable word matches var matches = Regex.Matches(text, unacceptableWordsPattern, RegexOptions.IgnoreCase | RegexOptions.Singleline); foreach (Match match in matches) { if (!blueWords.Contains(match.Value)) { blueWords.Add(match.Value); } } if (blueWords.Any()) { return(new ValidationResult(FormatErrorMessage(displayName, blueWords))); } } return(ValidationResult.Success); }
public JsonResult GetAutoCompleteItems(string text, int page) { var result = AdwService.GetListCodes("AZ1").ToSelectList(m => m.Code, m => m.Description); return(AjaxSelectionView(text, page, result)); }
public JsonResult GetOccupationLevel3(string text, int page, string occupationLevel2) { var result = AdwService.GetRelatedCodes("AZ24", occupationLevel2, true).ToCodeModelList().ToSelectList(m => m.Code, m => m.Description); return(AjaxSelectionView(text, page, result)); }
public JsonResult GetOccupationLevel1(string text, int page) { var result = AdwService.GetListCodes("AZ1").ToSelectList(m => m.Code, m => m.Description); return(AjaxSelectionView(text, page, result)); }
public void AdwServiceConstructor_ExpectedException() { var target = new AdwService(null, null, null, null); Assert.Fail("Expected Exception"); }
public JsonResult GetPostcode(string text, int page, string state) { var result = AdwService.GetRelatedCodes("STPC", state, true).ToCodeModelList().ToSelectList(m => m.Code, m => m.Description); return(AjaxSelectionView(text, page, result)); }
public JsonResult GetLocality(string text, int page, string postcode) { var result = AdwService.GetRelatedCodes("LPCC", postcode, true).ToCodeModelList().ToSelectList(m => m.Description, m => m.Description); return(AjaxSelectionView(text, page, result)); }
public JsonResult GetState(string text, int page) { var result = AdwService.GetListCodes("STT").ToSelectList(m => m.Code, m => m.Code); return(AjaxSelectionView(text, page, result)); }