public IEnumerable <SelectItem> GetTag(string id)
        {
            try
            {
                var tagsFromDb = DataContext.Tags;
                foreach (var tag in tagsFromDb)
                {
                    var si = new SelectItem();
                    si.id   = tag.Id;
                    si.text = tag.Name;
                    _tags.Add(si);
                }
            }

            catch (Exception e)
            {
                _tags = _tagsLocal;
            }

            if (string.IsNullOrWhiteSpace(id))
            {
                return(null);
            }

            var items = new List <SelectItem>();

            string[] idList = id.Split(new char[] { ',' });
            foreach (var idStr in idList)
            {
                int idInt;
                if (int.TryParse(idStr, out idInt))
                {
                    items.Add(_tags.FirstOrDefault(m => m.id == idInt));
                }
            }

            return(items);
        }
        public IEnumerable <SelectItem> SearchTag(string id)
        {
            try
            {
                var tagsFromDb = DataContext.Tags;
                foreach (var tag in tagsFromDb)
                {
                    var si = new SelectItem();
                    si.id   = tag.Id;
                    si.text = tag.Name;
                    _tags.Add(si);
                }
            }

            catch (Exception e)
            {
                _tags = _tagsLocal;
            }


            var query = _tags.Where(m => m.text.ToLower().Contains(id.ToLower()));

            return(query);
        }
        public IEnumerable <SelectItem> SearchCompany(string id)
        {
            try
            {
                var companiesFromDb = DataContext.Companies;
                foreach (var company in companiesFromDb)
                {
                    var si = new SelectItem();
                    si.id   = company.Id;
                    si.text = company.Name;
                    _companies.Add(si);
                }
            }

            catch (Exception e)
            {
                _companies = _companiesLocal;
            }


            var query = _companies.Where(m => m.text.ToLower().Contains(id.ToLower()));

            return(query);
        }