private static void Subject(List <object> data) { var name = data[0].ToString(); var equipment = data[1] as Equipment; var subjectType = data[2] as SubjectType; if (equipment == null) { throw new ArgumentNullException(nameof(equipment), "Не выбрано оборудование."); } if (subjectType == null) { throw new ArgumentNullException(nameof(subjectType), "Не выбран тип предмета."); } var subject = new Subject(name, equipment.Id, subjectType.Id); Insert <Subject> .InsertOriginal(subject, Select.Subjects()); }
private static void Subgroup(List <object> data) { var name = data[0].ToString(); if (!int.TryParse(data[1].ToString(), out int numberOfStudents)) { throw new ArgumentException("Не удалось преобразовать количество студентов в число", nameof(numberOfStudents)); } var group = data[2] as Group; if (group == null) { throw new ArgumentNullException(nameof(group), "Не выбрана группа."); } var subgroup = new Subgroup(name, numberOfStudents, group.Id); Insert <Subgroup> .InsertOriginal(subgroup, Select.Subgroups()); }
private static void Equipment(List <object> data) { var name = data[0].ToString(); if (!int.TryParse(data[1].ToString(), out int numberOfSeats)) { throw new ArgumentException("Вы ввели не число в поле \"Количество сидений\"", nameof(numberOfSeats)); } var equipment = new Equipment(name, numberOfSeats); Insert <Equipment> .InsertOriginal(equipment, Select.Equipment()); try { var specialEquipmentNames = data[2] as Dictionary <string, bool>; if (specialEquipmentNames.Count == 0) { return; } var specialEquipmentCollection = NamesToObjects <SpecialEquipment> .GetObjects(specialEquipmentNames, Select.SpecialEquipment()); foreach (var specialEquipment in specialEquipmentCollection) { var val = new SpecialEquipmentInEquipment(specialEquipment.Key.Id, equipment.Id); if (CheckForExistence <SpecialEquipmentInEquipment> .IsExist(val, Select.SpecialEquipmentInEquipment()) == true && specialEquipment.Value == false) { Delete <SpecialEquipmentInEquipment> .DeleteFromTable(val); } else if (CheckForExistence <SpecialEquipmentInEquipment> .IsExist(val, Select.SpecialEquipmentInEquipment()) == false && specialEquipment.Value == true) { Add <SpecialEquipmentInEquipment> .AddNew(val); } } } catch { } }
private static void FlowsLoad(List <object> data) { var subject = data[0] as Subject; var flow = Select.Flows().Where(x => x.Name == data[2].ToString()).FirstOrDefault(); if (flow == null) { throw new ArgumentNullException(nameof(flow), "Поток не выбран."); } if (subject == null) { throw new ArgumentNullException(nameof(subject), "Предмет не выбран."); } if (int.TryParse(data[1].ToString(), out int load) == false) { throw new ArgumentException("Вы ввели не число в поле \"Нагрузка\"", nameof(load)); } var flowsLoad = new FlowsLoad(flow.Id, subject.Id, load); Insert <FlowsLoad> .InsertOriginal(flowsLoad, Select.FlowsLoad()); }
private static void TeachersLoad(List <object> data) { var subject = data[0] as Subject; var teacher = Select.Teachers().Where(x => x.Name == data[2].ToString()).FirstOrDefault(); if (teacher == null) { throw new ArgumentNullException(nameof(teacher), "Преподаватель не выбран."); } if (subject == null) { throw new ArgumentNullException(nameof(subject), "Предмет не выбран."); } if (int.TryParse(data[1].ToString(), out int load) == false) { throw new ArgumentException("Вы ввели не число в поле \"Нагрузка\"", nameof(load)); } var teachersLoad = new TeachersLoad(subject.Id, teacher.Id, load); Insert <TeachersLoad> .InsertOriginal(teachersLoad, Select.TeachersLoads()); }
private static void AddSubgroupToLessonFrame(Subgroup subgroup, LessonFrame lessonFrame) { var subgroupInLessonFrame = new SubgroupsInLessonFrames(subgroup.Id, lessonFrame.Id); Insert <SubgroupsInLessonFrames> .InsertOriginal(subgroupInLessonFrame, Select.SubgroupsInLessonFrames()); }