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(); }
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(); }
public void DelElement(BoundExecutorModel model) { _service.deleteElement(model.ID); }
public void UpdElement(BoundExecutorModel model) { _service.updateElement(model); }
public void AddElement(BoundExecutorModel model) { _service.addElement(model); }