Esempio n. 1
0
        /// <summary>
        /// Метод определяет получение списка работодателей для формы
        /// </summary>
        public List <string[]> GetEmployers(string filter)
        {
            List <Employer> employers = Employer.GetAll();
            List <string[]> list      = new List <string[]>();

            //Не используется фильтр
            if (filter.Equals(""))
            {
                foreach (Employer current in employers)
                {
                    string[] tmp = new string[4];
                    tmp.SetValue(current.GetName(), 0);
                    tmp.SetValue(current.GetItn(), 1);
                    tmp.SetValue(current.GetAddress(), 2);
                    tmp.SetValue(current.GetPhone(), 3);
                    list.Add(tmp);
                }
            }
            //Используется фильтр
            else
            {
                foreach (Employer current in employers)
                {
                    string[] tmp = new string[4];

                    tmp.SetValue(current.GetName(), 0);
                    tmp.SetValue(current.GetItn(), 1);
                    tmp.SetValue(current.GetAddress(), 2);
                    tmp.SetValue(current.GetPhone(), 3);
                    //Проверка каждого поля на соответствие фильтру
                    for (int i = 0; i < tmp.Count(); i++)
                    {
                        if (tmp.ElementAt(i).IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) >= 0)
                        {
                            list.Add(tmp);
                            break;
                        }
                    }
                }
            }
            return(list);
        }