public static void RemoveFromDb(GroupSubject groupSubject) { if (db.GroupSubjects.Contains(groupSubject)) { db.GroupSubjects.Remove(groupSubject); } }
public async Task <IActionResult> Edit(long id, [Bind("Id,GroupId,SubjectId")] GroupSubject groupSubject) { if (id != groupSubject.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(groupSubject); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroupSubjectExists(groupSubject.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GroupId"] = new SelectList(_context.Groups, "Id", "Nomi", groupSubject.GroupId); ViewData["SubjectId"] = new SelectList(_context.Subjects, "Id", "Nomi", groupSubject.SubjectId); return(View(groupSubject)); }
public void AddSubject(ISubject subject) { string groupName = Grouping?.GetGroup(subject); lock (writeLock) { if (groupName != null) { if (groups.TryGetValue(groupName, out GroupSubject group)) { group.AddChild(subject); } else { group = new GroupSubject(groupName); group.AddChild(subject); groups[groupName] = group; AddSubjectUnderCategory(group); } } else { AddSubjectUnderCategory(subject); } } }
public static void UpdateGroupSubject(GroupSubject groupSubject, long GroupSubjectId = 0, long GroupSubjectGroupId = 0, long GroupSubjectSubjectId = 0, long GroupSubjectCount = 0) { groupSubject.Id = GroupSubjectId == 0 ? groupSubject.Id : GroupSubjectId; groupSubject.GroupId = GroupSubjectGroupId == 0 ? groupSubject.GroupId : GroupSubjectGroupId; groupSubject.SubjectId = GroupSubjectSubjectId == 0 ? groupSubject.SubjectId : GroupSubjectSubjectId; groupSubject.Count = GroupSubjectCount == 0 ? groupSubject.Count : GroupSubjectCount; }
private void btnAddSubject_Click(object sender, EventArgs e) { if (this.groups == null || this.groups.Count == 0 || this.groupDataGridView.SelectedRows.Count != 1) { MessageBox.Show("لطفا یک گروه انتخاب کنید."); return; } GroupSubject subject = new GroupSubject(); SubjectCategory.BaseSubjectForm bsf = new SubjectCategory.BaseSubjectForm(); bsf.MultiSelect = true; bsf.SetDontShowControls(); TaaliDataDataContext data = new TaaliDataDataContext(); bsf.Subjects = data.MajorSubjects.Where(ms => ms.MajorID == this.groups[this.dataSource.Position].MajorID).Select(ms => ms.Subject).ToList(); DialogResult dr = bsf.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { if (bsf.SelectedItems.SelectedItems == null || bsf.SelectedItems.SelectedItems.Count == 0) { return; } if (this.groups[this.dataSource.Position].Subjects == null || this.groups[this.dataSource.Position].Subjects.Count == 0) { this.groups[this.dataSource.Position].Subjects = bsf.SelectedItems.SelectedItems .OrderBy(sub => sub.SubjectID).ToList(); } else { List <Subject> subs = new List <Subject>(); subs.AddRange(this.groups[this.dataSource.Position].Subjects); subs.AddRange(from s in bsf.SelectedItems.SelectedItems where this.groups[this.dataSource.Position] .Subjects.Where(su => su.SubjectID == s.SubjectID).Count() == 0 select s); this.groups[this.dataSource.Position].Subjects = subs.OrderBy(sub => sub.SubjectID).ToList(); } this.groups = this.groups.OrderBy(g => g.Title).ToList(); this.refreshGridView(); this.subjectDataGridView.ClearSelection(); foreach (var s in bsf.SelectedItems.SelectedItems) { int i = this.groups[this.dataSource.Position].Subjects.IndexOf (this.groups[this.dataSource.Position].Subjects.Where (sub => sub.SubjectID == s.SubjectID).Single()); this.subjectDataGridView.Rows[i].Selected = true; } if (this.subjectDataGridView.RowCount > 0) { this.btnDeleteSubject.Enabled = true; } this.styleView(); } }
public static void UpdateInDb(GroupSubject groupSubject) { var groupSubjectToUpdate = db.GroupSubjects.Where(g => g.Id == groupSubject.Id).FirstOrDefault(); if (groupSubjectToUpdate != null) { db.GroupSubjects.Update(groupSubject); } }
public static void Serialize(string fileName, GroupSubject groupSubject) { XmlSerializer serializer = new XmlSerializer(typeof(GroupSubject)); using (FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate)) { serializer.Serialize(fs, groupSubject); } }
public void DeleteSubjectFromGroup(int subjectId, int groupId) { GroupSubject gs = dbContext.GroupSubject.Where(x => x.SubjectId == subjectId && x.GroupId == groupId).FirstOrDefault(); if (gs != null) { dbContext.GroupSubject.Remove(gs); dbContext.SaveChanges(); } }
public IHttpActionResult AddGroupSubject([FromBody] GroupSubject subject) { try { var model = new GroupSubject(); model.groupid = subject.groupid; model.name = subject.name; model.createtime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); model.isdel = 0; model.isend = 0; model.creator = subject.creator; model.remark = string.Empty; model.endtime = string.Empty; _unitOfWork.DGroupSubject.Insert(model); var result = _unitOfWork.Save(); if (result.ResultType == OperationResultType.Success) { return(Json(new { Success = true, Content = model, Error = "", Message = "操作成功", Count = 0, Total = 0 })); } LoggerHelper.Error(result.ToString()); return(Json(new { Success = false, Content = "", Error = result.Message, Message = "操作失败", Count = 0, Total = 0 })); } catch (Exception ex) { LoggerHelper.Error(ex.Message); return(Json( new { Success = false, Content = "", Error = ex.ToString(), Message = "操作失败", Count = 0, Total = 0 })); } }
public static void SerializeDb(string filename) { var groupSubjectsFromDb = db.GroupSubjects.ToArray(); var groupSubjectsToSerialize = new GroupSubject[groupSubjectsFromDb.Length]; for (int i = 0; i < groupSubjectsToSerialize.Length; i++) { groupSubjectsToSerialize[i] = CreateGroupSubject(groupSubjectsFromDb[i].Id, groupSubjectsFromDb[i].GroupId, groupSubjectsFromDb[i].SubjectId, groupSubjectsFromDb[i].Count); } SerializeArray(filename, groupSubjectsToSerialize); }
public IActionResult OnPost() { if (ModelState.IsValid) { Subject subject = new Subject(); foreach (var item in db.Subjects) { if (int.Parse(SubjectID) == item.IdSubject) { subject = item; } } SchoolGroup schoolGroup = new SchoolGroup(); foreach (var item in db.SchoolGroups) { if (int.Parse(GroupID) == item.IdGroup) { schoolGroup = item; } } if (schoolGroup.Name == null || subject.Name == null) { return(RedirectToPage("add_group_subject")); } bool flag = true; foreach (var groupSubject in GroupSubjects) { if (groupSubject.IdGroup == schoolGroup.IdGroup && groupSubject.IdSubject == subject.IdSubject) { flag = false; break; } } //If flag then is a new Groups SchoolGroup row if (flag) { GroupSubject GroupSubject = new GroupSubject() { IdGroup = schoolGroup.IdGroup, IdSubject = subject.IdSubject }; db.GroupSubjects.Add(GroupSubject); db.SaveChanges(); } } return(RedirectToPage("add_group_subject")); }
public static void GenerateGroupSubjects() { // GroupSubject for (int i = 1; i < 4; i++) { for (int j = 1; j < 12; j++) { GroupSubject gs = GroupSubjectRepo.CreateGroupSubject(i, j, 60); GroupSubjectRepo.AddToDb(gs); } } }
public async Task <IActionResult> Create([Bind("Id,GroupId,SubjectId")] GroupSubject groupSubject) { if (ModelState.IsValid) { _context.Add(groupSubject); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GroupId"] = new SelectList(_context.Groups, "Id", "Nomi", groupSubject.GroupId); ViewData["SubjectId"] = new SelectList(_context.Subjects, "Id", "Nomi", groupSubject.SubjectId); return(View(groupSubject)); }
public IHttpActionResult DeleteGroupSubject([FromBody] GroupSubject subject) { try { var query = _unitOfWork.DGroupSubject.Get(p => p.isdel == 0 && p.id == subject.id).FirstOrDefault();; if (query != null) { query.isdel = 1; _unitOfWork.DGroupSubject.Update(query); var result = _unitOfWork.Save(); if (result.ResultType == OperationResultType.Success) { return(Json(new { Success = true, Content = subject, Error = "", Message = "操作成功", Count = 1, Total = 1 })); } } return(Json(new { Success = false, Content = "", Error = "", Message = "操作失败", Count = 0, Total = 0 })); } catch (Exception ex) { LoggerHelper.Error(ex.Message); return(Json( new { Success = false, Content = "", Error = ex.ToString(), Message = "操作失败", Count = 0, Total = 0 })); } }
public void AddSubjectToGroup(int subjectId, int groupId) { if (dbContext.GroupSubject.Where(x => x.SubjectId == subjectId && x.GroupId == groupId).FirstOrDefault() == null) { GroupSubject gs = new GroupSubject() { SubjectId = subjectId, GroupId = groupId }; dbContext.GroupSubject.Add(gs); dbContext.SaveChanges(); } }
private void saveToTimeTable(Group group, Subject subject, Teacher teacher, Class classroom, IEnumerable <UniversityHoldingTime> times) { GroupSubject gropsub = this.groupSubjects.Where(gs => gs.GroupID == group.GroupID && gs.SubjectID == subject.SubjectID).Single(); if (this.timeTable.Where(tt => tt.GroupSubjectID == gropsub.GroupSubjectID).Count() != 0) { return; } foreach (var time in times) { if (this.timeTable.Where(tt => tt.TimeTeacher.TimeID == time.HoldingTimeID && tt.GroupSubject.TermYear == this.year && tt.GroupSubject.Semester == this.semester && tt.GroupSubject.GroupID == group.GroupID).Count() != 0) { return; } if (this.timeTable.Where(tt => tt.TimeTeacher.TeacherID == teacher.TeacherID && tt.TimeTeacher.TimeID == time.HoldingTimeID && tt.GroupSubject.TermYear == this.year && tt.GroupSubject.Semester == this.semester).Count() != 0) { return; } if (this.timeTable.Where(tt => tt.ClassID == classroom.ClassID && tt.TimeTeacher.TimeID == time.HoldingTimeID && tt.GroupSubject.TermYear == this.year && tt.GroupSubject.Semester == this.semester).Count() != 0) { return; } } foreach (var time in times) { TaaliDataDataContext taali = new TaaliDataDataContext(); TimeTeacher timeteach = taali.TimeTeachers.Where(tt => tt.TeacherID == teacher.TeacherID && tt.TimeID == time.HoldingTimeID).Single(); TimeTable table = new TimeTable(); if (classroom.ClassID != 0 && gropsub.GroupSubjectID != 0 && timeteach.TimeTeacherID != 0) { table.Class = classroom; table.GroupSubject = gropsub; table.TimeTeacher = timeteach; this.timeTable.Add(table); } } }
public async Task <IOutput> Handle(CreateScheduleInput request, CancellationToken cancellationToken) { var group = await _context.Groups .Include(x => x.GroupSubjects) .FirstOrDefaultAsync(x => x.Id == request.GroupId, cancellationToken); if (group is null) { return(Failure("Группа не найдена")); } var subject = await _context.Subjects .FirstOrDefaultAsync(x => x.Id == request.SubjectId, cancellationToken); if (subject is null) { return(Failure("Предмет не найден")); } var groupSubject = new GroupSubject { DurationInMinutes = request.DurationInMinutes, StartDate = request.StartDate, Group = group, GroupId = group.Id, Subject = subject, SubjectId = subject.Id, ManualCreated = true, }; _context.GroupSubjects.Add(groupSubject); await _context.SaveChangesAsync(cancellationToken); return(ObjectOutput.CreateWithId(groupSubject.Id)); }
public virtual void Insert(GroupSubject grsubj) { context.GroupSubject.Add(grsubj); context.SaveChanges(); }
protected override void btnOK_Click(object sender, EventArgs e) { if (!this.boxValidation()) { return; } bool done = false; GroupSubject gropsub = new GroupSubject(); try { if (this.taali.GroupSubjects.Where(gs => gs.GroupID == TheGroup.GroupID && gs.SubjectID == TheSubject.SubjectID && gs.TermYear == this.Year && gs.Semester == this.Semester).Count() == 1) { gropsub = this.taali.GroupSubjects.Where(gs => gs.GroupID == TheGroup.GroupID && gs.SubjectID == TheSubject.SubjectID && gs.TermYear == this.Year && gs.Semester == this.Semester).Single(); } else { gropsub = new GroupSubject(); gropsub.Semester = this.Semester; gropsub.TermYear = this.Year; gropsub.Group = this.taali.Groups.Where(g => g.GroupID == this.TheGroup.GroupID) .Single(); gropsub.Subject = this.taali.Subjects.Where(s => s.SubjectID == this.TheSubject.SubjectID).Single(); this.taali.GroupSubjects.InsertOnSubmit(gropsub); this.taali.SubmitChanges(); done = true; gropsub = this.taali.GroupSubjects.Where(gs => gs.GroupID == TheGroup.GroupID && gs.SubjectID == TheSubject.SubjectID && gs.TermYear == this.Year && gs.Semester == this.Semester).Single(); } if (this.TimeTableCells.Where(tt => tt.GroupSubjectID == gropsub.GroupSubjectID) .Count() != 0) { throw new Exception("این درس در این ترم برای این گروه ارایه شده است."); } foreach (var time in Times) { if (this.TimeTableCells.Where(tt => tt.TimeTeacher.TimeID == time.HoldingTimeID && tt.GroupSubject.TermYear == this.Year && tt.GroupSubject.Semester == this.Semester && tt.GroupSubject.GroupID == TheGroup.GroupID).Count() != 0) { throw new Exception(string.Format(@"{0}'{1}'{2}", "برای گروه مورد نظر شما در این ساعت ", time.ToString(), "یک در ارایه شده است.")); } if (this.TimeTableCells.Where(tt => tt.TimeTeacher.TeacherID == TheTeacher.TeacherID && tt.TimeTeacher.TimeID == time.HoldingTimeID && tt.GroupSubject.TermYear == this.Year && tt.GroupSubject.Semester == this.Semester).Count() != 0) { throw new Exception(string.Format(@"{0}'{1}'{2}", "استاد مورد نظر شما در این ساعت ", time.ToString(), "تدریس می کند.")); } if (this.TimeTableCells.Where(tt => tt.ClassID == TheClass.ClassID && tt.TimeTeacher.TimeID == time.HoldingTimeID && tt.GroupSubject.TermYear == this.Year && tt.GroupSubject.Semester == this.Semester).Count() != 0) { throw new Exception(string.Format(@"{0}'{1}'{2}", "کلاس مورد نظر شما در این ساعت ", time.ToString(), "پر می باشد.")); } } foreach (var time in Times) { TaaliDataDataContext taali = new TaaliDataDataContext(); var timteas = taali.TimeTeachers.Where(tt => tt.TeacherID == TheTeacher.TeacherID && tt.TimeID == time.HoldingTimeID); if (timteas.Count() != 1) { string error = "استاد مورد نظر شما دراین ساعت نمی تواند تدریس کند."; throw new Exception(error); } TimeTeacher timeteach = timteas.Single(); TimeTable table = new TimeTable(); if (TheClass.ClassID != 0 && gropsub.GroupSubjectID != 0 && timeteach.TimeTeacherID != 0) { table.Class = this.taali.Classes.Where(c => c.ClassID == this.TheClass.ClassID).Single(); table.GroupSubject = this.taali.GroupSubjects.Where(gs => gs.GroupSubjectID == gropsub.GroupSubjectID).Single(); table.TimeTeacher = this.taali.TimeTeachers.Where(tt => tt.TimeTeacherID == timeteach.TimeTeacherID).Single(); this.TimeTableCells.Add(table); } } this.DialogResult = System.Windows.Forms.DialogResult.OK; } catch (Exception ex) { if (done) { this.taali.GroupSubjects.DeleteAllOnSubmit(this.taali.GroupSubjects .Where(gs => gs.GroupSubjectID == gropsub.GroupSubjectID)); this.taali.SubmitChanges(); } MessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } }
public static void AddToDb(GroupSubject groupSubject) { db.GroupSubjects.Add(groupSubject); db.SaveChanges(); }
public Subject GetSubject(GroupSubject groupSubject) { return(helper.GetSubject(groupSubject.IdSubject)); }
public async Task Parse(Stream file) { var extractResult = await _mediator.Send(new ExtractSubjectsFromFileInput(file)); var startTime = extractResult.TimeStart.Equals("8:30") ? TimeSpan.FromMinutes(8 * 60 + 30) : TimeSpan.FromMinutes(12 * 60 + 30); foreach (var group in extractResult.Groups) { await _context.GroupSubjects .Where(x => x.StartDate.Day == extractResult.Date.Day) .Where(x => x.StartDate.Year == extractResult.Date.Year) .Where(x => x.StartDate.Month == extractResult.Date.Month) .Where(x => x.Group.Name == group.Name) .Where(x => !x.ManualCreated) .Where(x => !x.ManualDeleted) .DeleteAsync(); var sorted = group.Subjects .OrderBy(x => x.Number) .ToList(); foreach (var subject in sorted) { if (string.IsNullOrEmpty(subject.SubjectName)) { continue; } Teacher teacher = null; if (!string.IsNullOrEmpty(subject.Teacher)) { teacher = await _context.Teachers.FirstOrDefaultAsync(x => x.ParsedName == subject.Teacher); if (teacher is null) { teacher = new Teacher { Name = subject.Teacher, ParsedName = subject.Teacher, }; _context.Teachers.Add(teacher); await _context.SaveChangesAsync(); } } var foundSubject = await _context.Subjects.FirstOrDefaultAsync(x => x.ParsedName == subject.SubjectName && x.Teacher == teacher); if (foundSubject is null) { foundSubject = new Subject { Name = subject.SubjectName, ParsedName = subject.SubjectName, Teacher = teacher, TeacherId = teacher?.Id }; _context.Subjects.Add(foundSubject); await _context.SaveChangesAsync(); } var foundGroup = await _context.Groups.FirstOrDefaultAsync(x => x.Name == group.Name); if (foundGroup is null) { foundGroup = new Group(group.Name); _context.Groups.Add(foundGroup); await _context.SaveChangesAsync(); } var groupSubject = new GroupSubject { DurationInMinutes = 95, Group = foundGroup, GroupId = foundGroup.Id, StartDate = extractResult.Date.Add(AddTime(startTime, subject.Number, extractResult)), Subject = foundSubject, SubjectId = foundSubject.Id, }; var any = await _context.GroupSubjects .Where(x => x.ManualDeleted) .Where(x => x.StartDate == groupSubject.StartDate) .Where(x => x.GroupId == groupSubject.GroupId) .Where(x => x.SubjectId == groupSubject.SubjectId) .AnyAsync(); if (any) { continue; } _context.GroupSubjects.Add(groupSubject); await _context.SaveChangesAsync(); } } }
private void OkClick(object sender, RoutedEventArgs e) { if (name.Text.Length > 0 && studentList.Items.Count > 0 && subjectList.Items.Count > 0) { if (this.GroupNameExist() == true) // jezeli w bazie istnieje juz grupa o takiej nazwie { MessageBox.Show("Grupa o takiej nazwie już istnieje!!", "Grupa", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (name.Text.Length > 20) { MessageBox.Show("Zbyt długa nazwa", "Grupa", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (Group == null) // gdy tworzymy nową grupę { Group = new Group(); Group.Name = name.Text; _context.Group.Add(Group); this.SaveDB(); // pobranie dodanej grupy z serwera, aby określić jego ID Group = _context.Group.First(g => g.Name == Group.Name); // przypisanie listy uczniów foreach (Student student in studentList.Items) { GroupStudent gs = new GroupStudent { GroupId = Group.Id, StudentId = student.Id, Group = Group, Student = student }; _context.GroupStudent.Add(gs); this.SaveDB(); } // przypisanie listy przedmiotów foreach (Subject subject in subjectList.Items) { GroupSubject gs = new GroupSubject { GroupId = Group.Id, SubjectId = subject.Id, Group = Group, Subject = subject }; _context.GroupSubject.Add(gs); this.SaveDB(); } } else // gdy edytujemy dane grupy { Group.Name = name.Text; _context.Attach(Group).State = EntityState.Modified; this.SaveDB(); // pomocnicza zmienna do flagowania znajdowania obiektów bool found = false; /// edycja listy uczniów // iteracja po liście studentów foreach (Student student in studentList.Items) { found = false; // iteracja po rekordach w bazie foreach (GroupStudent gr in GroupStudentList) { if (gr.Student.Id == student.Id) { found = true; break; } } // jeśli jest na liście studentów, ale nie ma go w bazie if (found == false) { GroupStudent gs = new GroupStudent { GroupId = Group.Id, StudentId = student.Id, Group = Group, Student = student }; _context.GroupStudent.Add(gs); this.SaveDB(); } } // iteracja po rekordach w bazie foreach (GroupStudent gr in GroupStudentList) { // jeśli jest w bazie, a nie ma go na liście studentów if (!studentList.Items.Contains(gr.Student)) { _context.GroupStudent.Remove(gr); this.SaveDB(); } } /// edycja listy przedmiotów // iteracja po liście przedmiotów foreach (Subject subject in subjectList.Items) { found = false; // iteracja po rekordach w bazie foreach (GroupSubject gr in GroupSubjectList) { if (gr.Subject.Id == subject.Id) { found = true; break; } } // jeśli jest na liście przedmiotów, ale nie ma go w bazie if (found == false) { GroupSubject gs = new GroupSubject { GroupId = Group.Id, SubjectId = subject.Id, Group = Group, Subject = subject }; _context.GroupSubject.Add(gs); this.SaveDB(); } } // iteracja po rekordach w bazie foreach (GroupSubject gr in GroupSubjectList) { // jeśli jest w bazie, a nie ma go na liście studentów if (!subjectList.Items.Contains(gr.Subject)) { _context.GroupSubject.Remove(gr); this.SaveDB(); } } } this.SaveDB(); DialogResult = true; } else { MessageBox.Show("Brak wszystkich danych", "Grupa", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public static long?GetGroupSubjectCount(GroupSubject groupSubject) { return(groupSubject.Count); }
private void AddGroupSubjectQueries(GroupSubjectFacade groupSubjectFacade, SubjectFacade subjectFacade, UserFacade userFacade) { Field <ListGraphType <GroupSubjectType> >( "allGroupSubjects", resolve: context => groupSubjectFacade.GetAll() ); Field <ListGraphType <GroupSubjectType> >("subjectListOnWeek", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "groupId" }), resolve: context => { var groupId = context.GetArgument <int>("groupId"); IEnumerable <GroupSubject> groupSubjects = groupSubjectFacade.GetByGroupId(groupId); foreach (var groupSubject in groupSubjects) { groupSubject.Subject = subjectFacade.GetById(groupSubject.SubjectId); groupSubject.Teacher = userFacade.GetById(groupSubject.TeacherId); } return(groupSubjects); } ); Field <ListGraphType <GroupSubjectType> >("subjectsForTeacher", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "teacherId" }), resolve: context => { var teacherId = context.GetArgument <int>("teacherId"); IEnumerable <GroupSubject> groupSubjects = groupSubjectFacade.GetScheduleByTeacherId(teacherId); foreach (var groupSubject in groupSubjects) { groupSubject.Subject = subjectFacade.GetById(groupSubject.SubjectId); groupSubject.Teacher = userFacade.GetById(groupSubject.TeacherId); } return(groupSubjects); } ); Field <ListGraphType <GroupSubjectType> >("teachersDisabled", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "dayOfWeek" }, new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "orderNumber" }, new QueryArgument <ListGraphType <IntGraphType> > { Name = "teachers" }), resolve: context => { var teachers = context.GetArgument <List <int> >("teachers"); var dayOfWeek = context.GetArgument <int>("dayOfWeek"); var orderNumber = context.GetArgument <int>("orderNumber"); List <GroupSubject> groupSubjects = new List <GroupSubject>(); foreach (var teacher in teachers) { GroupSubject groupSubject = groupSubjectFacade.GetByDayAndOrderAndTeacher(dayOfWeek, orderNumber, teacher); if (groupSubject != null) { groupSubjects.Add(groupSubject); } } return(groupSubjects); } ); Field <ListGraphType <GroupSubjectType> >("subjectsOnDay", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "groupId" }, new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "dayOfWeek" }), resolve: context => { var groupId = context.GetArgument <int>("groupId"); var dayOfWeek = context.GetArgument <int>("dayOfWeek"); return(groupSubjectFacade.GetByDayAndGroup(groupId, dayOfWeek)); } ); Field <GroupSubjectType>("groupSubject", arguments: new QueryArguments(new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <int?>("id"); return(id != null ? (groupSubjectFacade.GetById((int)id)) : null); } ); }
public void InsertGroupSubject(GroupSubject grsubj) { uof.GroupSubjectRepository.Insert(grsubj); uof.Save(); }
public static long?GetGroupSubjectSubjectId(GroupSubject groupSubject) { return(groupSubject.SubjectId); }