Beispiel #1
0
        public IHttpActionResult GetTag(int id)
        {
            TagDto tag = _tagAppService.Find(id);

            if (tag == null)
            {
                return(NotFound());
            }

            return(Ok(tag));
        }
        //search
        public ActionResult AutoComplete(string term)
        {
            term = term?.ToLower();
            ICollection <QueryFilter> filters = new List <QueryFilter>();
            QueryFilter filter = new QueryFilter("Name", term, Operator.StartsWith);

            filters.Add(filter);

            string result            = _appService.Find(filters);
            IEnumerable <TagVm> tags = string.IsNullOrEmpty(result)
                ? new List <TagVm>().Select(t => new TagVm {
                Name = string.Empty
            })
                : JsonConvert.DeserializeObject <IEnumerable <TagVm> >(result);

            var model = tags.Select(l => new
            {
                label = l.Name
            });

            return(JsonResult(model));
        }