Exemplo n.º 1
0
        public JsonResult GetItemNum(string term)
        {
            List <string> itemList;

            if (string.IsNullOrEmpty(term))
            {
                itemList = _stationeryRepo.GetAllItemNum().ToList();
            }
            else
            {
                itemList = _stationeryRepo.GetAllItemNum().ToList()
                           .FindAll(x => x.StartsWith(term, StringComparison.OrdinalIgnoreCase));
            }

            return(Json(itemList, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     if (value != null)
     {
         var valueAsString       = value.ToString();
         StationeryRepository sr = new StationeryRepository();
         if (!sr.GetAllItemNum().ToList().Contains(valueAsString))
         {
             var errorMessage = FormatErrorMessage(validationContext.DisplayName);
             return(new ValidationResult(errorMessage));
         }
     }
     return(ValidationResult.Success);
 }