public void addElement(BoundExecutorModel model)
        {
            Executor element = context.Executors.FirstOrDefault(rec => rec.ExecutorFullName == model.ExecutorFullName);

            if (element != null)
            {
                throw new Exception("Уже есть сотрудник с таким ФИО");
            }
            context.Executors.Add(new Executor
            {
                ExecutorFullName = model.ExecutorFullName
            });
            context.SaveChanges();
        }
예제 #2
0
        public void addElement(BoundExecutorModel model)
        {
            Executor element = source.Executors.FirstOrDefault(rec => rec.ExecutorFullName == model.ExecutorFullName);

            if (element != null)
            {
                throw new Exception("Уже есть сотрудник с таким ФИО");
            }
            int maxId = source.Executors.Count > 0 ? source.Executors.Max(rec => rec.ID) : 0;

            source.Executors.Add(new Executor
            {
                ID = maxId + 1,
                ExecutorFullName = model.ExecutorFullName
            });
        }
        public void updateElement(BoundExecutorModel model)
        {
            Executor element = context.Executors.FirstOrDefault(rec =>
                                                                rec.ExecutorFullName == model.ExecutorFullName && rec.ID != model.ID);

            if (element != null)
            {
                throw new Exception("Уже есть сотрудник с таким ФИО");
            }
            element = context.Executors.FirstOrDefault(rec => rec.ID == model.ID);
            if (element == null)
            {
                throw new Exception("Элемент не найден");
            }
            element.ExecutorFullName = model.ExecutorFullName;
            context.SaveChanges();
        }
예제 #4
0
 public void DelElement(BoundExecutorModel model)
 {
     _service.deleteElement(model.ID);
 }
예제 #5
0
 public void UpdElement(BoundExecutorModel model)
 {
     _service.updateElement(model);
 }
예제 #6
0
 public void AddElement(BoundExecutorModel model)
 {
     _service.addElement(model);
 }