Esempio n. 1
0
        public void AddElement(CustomerBindModel model)
        {
            int maxId = 0;

            for (int i = 0; i < source.Customers.Count; ++i)
            {
                if (source.Customers[i].ID > maxId)
                {
                    maxId = source.Customers[i].ID;
                }
                if (source.Customers[i].CustomerFIO == model.CustomerFIO)
                {
                    throw new Exception("Уже есть клиент с таким ФИО");
                }
            }
            source.Customers.Add(new Customer {
                ID = maxId + 1, CustomerFIO = model.CustomerFIO
            });
        }
Esempio n. 2
0
        public void UpdElement(CustomerBindModel model)
        {
            int index = -1;

            for (int i = 0; i < source.Customers.Count; ++i)
            {
                if (source.Customers[i].ID == model.ID)
                {
                    index = i;
                }
                if (source.Customers[i].CustomerFIO == model.CustomerFIO &&
                    source.Customers[i].ID != model.ID)
                {
                    throw new Exception("Уже есть клиент с таким ФИО");
                }
            }
            if (index == -1)
            {
                throw new Exception("Элемент не найден");
            }
            source.Customers[index].CustomerFIO = model.CustomerFIO;
        }