public void LoadGroups(string path) { XmlGroups.root root = GetXmlData <XmlGroups.root>(path); try { using (Entities db = new Entities()) { foreach (XmlGroups.rootGroup rootData in root.group) { db.Groups.Add(_CastDTO.DTOToGroup(new GroupDTO() { Num = rootData.num, Teacher = rootData.tea, Subject = rootData.subj, Room = rootData.sroom, Hours = rootData.no_of_hours, CalculateHours = rootData.calculate_hours, SchoolType = rootData.schooltype, Reforma = rootData.reforma, PayAbsence = rootData.goremMeshalem, HourType = rootData.sug, SubHourType = rootData.sub_sug })); } db.SaveChanges(); } } catch (Exception e) { LogManager.LogException(e); } }
public void LoadGroups(string path) { XmlGroups.root root = GetXmlData <XmlGroups.root>(path); try { using (Entities db = new Entities()) { foreach (XmlGroups.rootGroup rootData in root.group) { var t = _CastDTO.DTOToGroup(new GroupDTO() { Num = rootData.num, Teacher = rootData.tea == -1 ? null : (int?)rootData.tea, Subject = rootData.subj == -1 ? null : (int?)rootData.subj, Room = rootData.sroom == -1 || rootData.sroom > 200 ? null : (int?)rootData.sroom, Hours = rootData.no_of_hours, CalculateHours = rootData.calculate_hours, SchoolType = rootData.schooltype == 0 ? null : (int?)rootData.schooltype, Reforma = rootData.reforma, PayAbsence = rootData.goremMeshalem == 0 ? null : (int?)rootData.goremMeshalem, HourType = null, //TODO rootData.sug == 0 ? null : (int?)rootData.sug, SubHourType = null, // rootData.sub_sug == 0 ? null : (int?)rootData.sub_sug, }); db.Groups.Add(t); t.Classes = rootData.classes.Select(c => db.Classes.FirstOrDefault(cl => cl.Num == c.num)).ToList(); } db.SaveChanges(); } } catch (Exception e) { LogManager.LogException(e); } }