// PUT: api/Lesson/5 public HttpResponseMessage Put(int id, [FromBody] lesson value) { try { using (QLMamNonEntities db = new QLMamNonEntities()) { lesson s = db.lessons.SingleOrDefault(b => b.id == id); if (s != null) { s.id_plan = value.id_plan; s.id_staff = value.id_staff; s.name = value.name; s.content = value.content; s.time_start = value.time_start; s.time_end = value.time_end; return(Request.CreateResponse(HttpStatusCode.OK, new lessonDTO(s.id, Convert.ToInt64(s.id_plan), Convert.ToInt64(s.id_staff), s.name, s.content, s.time_start.ToString(), s.time_end.ToString()))); } else { return(null); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public lesson CreateLesson(lesson lesson) { _context.lessons.Add(lesson); _context.SaveChanges(); return(lesson); }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "del") { using (var db = new CstwebEntities()) { int id = Convert.ToInt32(e.CommandArgument); var le1 = db.lesrelation.Where(a => a.lesson == id).ToList(); try { db.lesrelation.Remove(le1[0]); db.SaveChanges(); } catch { } try { db.lesrelation.Remove(le1[1]); db.SaveChanges(); } catch { } try { db.lesrelation.Remove(le1[2]); db.SaveChanges(); } catch { } lesson les = db.lesson.FirstOrDefault(a => a.id == id); db.lesson.Remove(les); db.SaveChanges(); Response.Write("<script>alert('删除成功');window.location = 'lessons.aspx';</script>"); } } }
public HttpResponseMessage Get(int id) { List <student_lesson> student_Lessons = barkode_ProjectEntities.student_lesson.Where(x => x.student_id == id).ToList(); List <LessonSender> lessonSenders = new List <LessonSender>(); foreach (student_lesson st in student_Lessons) { lesson lesson = barkode_ProjectEntities.lesson.Where(x => x.lesson_id == st.lesson_id).FirstOrDefault(); LessonSender lessonSender = new LessonSender() { lesson_id = lesson.lesson_id, lesson_expiration_time = lesson.lesson_expiration_time.ToString(), lesson_name = lesson.lesson_name, lesson_onset_time = lesson.lesson_onset_time.ToString() }; lessonSenders.Add(lessonSender); } if (lessonSenders != null) { message = Request.CreateResponse(HttpStatusCode.OK, lessonSenders); return(message); } message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Ders Bulunamadi"); return(message); }
public int GetFirstExerciseNumberFromLesson(lesson lesson) { var listOfExercises = lesson.exercises.Select(ex => ex.exercise_number).ToList(); listOfExercises.Sort(); return(listOfExercises.FirstOrDefault()); }
protected void FindSession() { try { using (var db = new CstwebEntities()) { lesson les = (lesson)Session["less"]; TxtLessonName.Text = les.classname; TxtTeach.Text = les.teach.ToString(); TxtExp.Text = les.experiment.ToString(); TxtCredits.Text = les.credits.ToString(); DDLClass.SelectedValue = les.lesscla.ToString(); int id; if (Session["First1"] == null) { Label1.Text = "0"; LinFirst1.Text = "先修课程1"; } else { Label1.Text = Session["First1"].ToString(); id = Convert.ToInt32(Label1.Text); LinFirst1.Text = db.lesson.First(a => a.id == id).classname.ToString();; } if (Session["First2"] == null) { LinFirst2.Text = "先修课程2"; Label2.Text = "0"; } else { Label2.Text = Session["First2"].ToString(); id = Convert.ToInt32(Label2.Text); LinFirst2.Text = db.lesson.First(a => a.id == id).classname.ToString();; } if (Session["First3"] == null) { LinFirst3.Text = "先修课程3"; Label3.Text = "0"; } else { Label3.Text = Session["First3"].ToString(); id = Convert.ToInt32(Label3.Text); LinFirst3.Text = db.lesson.First(a => a.id == id).classname.ToString();; } Session["FList"] = null; Session["Less"] = null; Session["First1"] = null; Session["First2"] = null; Session["First3"] = null; } } catch { } }
public ChooseExerciseWindow(user user, lesson lesson) { _lesson = lesson; _user = user; _exerciseService = new ExerciseService(); _lessonService = new LessonService(); InitializeComponent(); PrepareExercisesButtons(false); }
/// <summary> /// 查询,根据课程代码查详细信息 /// </summary> /// <param name="Lesson"></param> /// <returns></returns> public DataTable GetSubjectDetail(lesson Lesson) { string QuerySql = "select * from lesson where lessonCode=@lessonCode"; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@lessonCode", Lesson.LessonCode), }; DataTable dt = DAO.databaseContorl.GetDataSet(QuerySql, parameters); return(dt); }
private JObject selectStart(Command value) { var lessonTDS = JsonConvert.DeserializeObject <LessonTimeAndDateSetter>(value.data.ToString()); lesson lesson = _db.getLesson(lessonTDS.id); lesson.iddays = lessonTDS.day; lesson.start = lessonTDS.startsAt; lesson.idclassrooms = lessonTDS.classroom; _db.updateLesson(lessonTDS.id, lesson); return(JObject.Parse(JsonConvert.SerializeObject(lessonTDS))); }
// GET: api/Lesson/5 public lessonDTO Get(int id) { using (QLMamNonEntities db = new QLMamNonEntities()) { lesson s = db.lessons.SingleOrDefault(x => x.id == id); if (s != null) { return(new lessonDTO(s.id, Convert.ToInt64(s.id_plan), Convert.ToInt64(s.id_staff), s.name, s.content, s.time_start.ToString(), s.time_end.ToString())); } else { return(null); } } }
protected void FindQuery() { try { int id = Convert.ToInt32(Request.QueryString["id"]); Session["lessonID"] = id.ToString(); using (var db = new CstwebEntities()) { lesson les = db.lesson.First(a => a.id == id); TxtLessonName.Text = les.classname; TxtTeach.Text = les.teach.ToString(); TxtExp.Text = les.experiment.ToString(); TxtCredits.Text = les.credits.ToString(); try { LblFilename.Text = les.lesfile; } catch { } myEditor.InnerHtml = les.etc; DDLClass.SelectedValue = les.lesclass.ToString(); var less = db.lesrelation.Where(a => a.lesson == id).ToList(); try { id = Convert.ToInt32(less[0].firstlesson); Label1.Text = id.ToString(); LinFirst1.Text = db.lesson.First(a => a.id == id).classname; try { id = Convert.ToInt32(less[1].firstlesson); Label2.Text = id.ToString(); LinFirst2.Text = db.lesson.First(a => a.id == id).classname; try { id = Convert.ToInt32(less[2].firstlesson); Label3.Text = id.ToString(); LinFirst3.Text = db.lesson.First(a => a.id == id).classname; } catch { } } catch { } } catch { } } } catch { } }
public void CreateLessonsForNewUser(user newUser) { foreach (var lessonSetup in _lessonsSetupRepository.GetAllLessonsSetup()) { var lesson = new lesson { user_id = newUser.id, lesson_number = lessonSetup.lesson_number, is_done = false }; lesson = _lessonRepository.CreateLesson(lesson); _exerciseService.CreateExercisesForNewLesson(lesson); } }
// POST: api/Lesson public HttpResponseMessage Post([FromBody] lesson obj) { try { using (QLMamNonEntities db = new QLMamNonEntities()) { db.lessons.Add(obj); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created, obj)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public void CreateExercisesForNewLesson(lesson lesson) { int lessonSetupId = _lessonsSetupRepository.GetLessonSetupIdByLessonNumber(lesson.lesson_number); foreach (var exerciseSetup in _exercisesSetupRepository.GetExercisesSetupByLessonSetupId(lessonSetupId)) { var exercise = new exercis { exercise_number = exerciseSetup.exercise_number, lesson_id = lesson.id, is_done = false }; _exerciseRepository.CreateExercise(exercise); } }
private void addSubject(Lesson it, string groupID) { lesson lesson = new lesson(); lesson.idlessons = Guid.NewGuid().ToString().Replace("-", ""); lesson.idteachers = it.teacher_id; lesson.idsubjects = findSubjectID(it.name, it.type, it.duration); lesson.idgroups = groupID; try { _db.insertLesson(ref lesson); } catch (DbEntityValidationException e) { Console.WriteLine(e); } }
// DELETE: api/Lesson/5 public HttpResponseMessage Delete(int id) { try { using (QLMamNonEntities db = new QLMamNonEntities()) { lesson s = db.lessons.SingleOrDefault(x => x.id == id); db.lessons.Remove(s); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public ActionResult Barcode(session session) { string text = RandomSerialGenerator.generator().ToString(); barcode barcode = new barcode(); session.session_content = text; barcode.barcode_content = text; session.session_onset_time = DateTime.Now; session.session_expiration_time = DateTime.Now.AddMinutes(5); lesson lesson = db.lesson.Where(x => x.lesson_id == session.lesson_id).FirstOrDefault(); session.lesson = lesson; db.barcode.Add(barcode); session.barcode = barcode; db.session.Add(session); db.SaveChanges(); return(RedirectToAction("index", "home", new { @text = text })); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; student Student = new student(); if (context.Session["id"] != null) { Student.ID = context.Session["id"].ToString(); string sql = "select lessonCode from lessonTable where stuId='" + Student.ID + "'"; databaseContorl dbs = new databaseContorl(); DataTable dt = dbs.GetDataAdapter(sql); DataRow[] dr = dt.Select(); if (dt.Rows.Count > 0) { string Course = dr[0]["lessoncode"].ToString(); string[] everyCourse = Course.Split('@'); lesson Lesson = new lesson(); string strCourse = string.Empty; stuMgr StuMgr = new stuMgr(); foreach (string course in everyCourse) { Lesson.LessonCode = course; DataRow[] dataRows = StuMgr.GetSubjectDetail(Lesson).Select(); foreach (DataRow dar in dataRows) { strCourse += "<tr><td>" + dar["lessonName"] + "</td><td>" + dar["lessonTeam"] + "</td><td>" + dar["lessonTeacher"] + "</td><td>" + dar["lessonStartTime"] + "~" + dar["lessonEndTime"] + "</td><td>" + dar["lessonAddress"] + "</td>/tr>"; } } context.Response.Write(strCourse); } else { context.Response.Write("你还没有选课"); } } else { context.Response.Write("fail"); } }
private List <List <TimeSuggestion> > getPossibleTimeSlots(List <List <TimeSlot> > combinedTimeSlots, lesson lesson) { var timeSuggestions = new List <List <TimeSuggestion> >(); var duration = lesson.subject.time.GetValueOrDefault(); foreach (var day in combinedTimeSlots) { var timeSuggestionForADay = new List <TimeSuggestion>(); for (var timeSlot = 0; timeSlot < (day.Count - duration); ++timeSlot) { bool aviable = true; for (int currentTime = 0; currentTime < duration; currentTime++) { if (day.ElementAt(timeSlot + currentTime).Availability == Availability.NonAvailable) { aviable = false; break; } } if (aviable) { timeSuggestionForADay.Add(new TimeSuggestion { startsAt = timeSlot, duration = duration, possibleClassrooms = new List <Classroom>() }); } } timeSuggestions.Add(timeSuggestionForADay); } return(timeSuggestions); }
public void tijiao() { for (int i = 0; i < Go.Count; i++) { for (int l = 0; l < Go.Count; l++) { if (i == l) { continue; } if (Go[i].transform.Find("星期").GetComponent <Dropdown>().value == Go[l].transform.Find("星期").GetComponent <Dropdown>().value && Go[i].transform.Find("天").GetComponent <Dropdown>().value == Go[l].transform.Find("天").GetComponent <Dropdown>().value) { tip.SetActive(true); tip.transform.Find("Text").GetComponent <Text>().text = "上课时间冲突"; return; } } } for (int i = 0; i < 12; i++) { if (All.Classes[i].Academyindex == academyindex && All.Classes[i].Subjectindex == subjectindex) { index = i; break; } } lesson Le = new lesson(); All.classID++; Le.ID = All.classID; Le.name = Name.text; Le.jieshu = int.Parse(jieshu.text); Le.times = new List <string>(); if (Le.daytimes == null) { Le.daytimes = new List <int>(); } if (Le.weektimes == null) { Le.weektimes = new List <int>(); } for (int i = 0; i < Go.Count; i++) { Debug.Log(weektime[Go[i].transform.Find("星期").GetComponent <Dropdown>().value] + " " + daytime[Go[i].transform.Find("天").GetComponent <Dropdown>().value]); Le.times.Add(weektime[Go[i].transform.Find("星期").GetComponent <Dropdown>().value] + " " + daytime[Go[i].transform.Find("天").GetComponent <Dropdown>().value]); Le.daytimes.Add(Go[i].transform.Find("天").GetComponent <Dropdown>().value); Le.weektimes.Add(Go[i].transform.Find("星期").GetComponent <Dropdown>().value); foreach (string str in classtimes) { for (int j = 0; j < Le.daytimes.Count; j++) { if (str == ((Le.daytimes[j] + 1) * 10 + Le.weektimes[j]).ToString()) { tip.SetActive(true); tip.transform.Find("Text").GetComponent <Text>().text = "时间重复!"; return; } } } } if (All.Classes[index].Lessons == null) { All.Classes[index].Lessons = new List <lesson>(); } foreach (lesson Lesson in All.Classes[index].Lessons) { if (Lesson.name == Le.name) { tip.SetActive(true); tip.transform.Find("Text").GetComponent <Text>().text = "课程名字重复!"; return; } } for (int j = 0; j < Le.daytimes.Count; j++) { classtimes.Add(((Le.daytimes[j] + 1) * 10 + Le.weektimes[j]).ToString()); } All.Classes[index].Lessons.Add(Le); Debug.Log(All.Classes[index].Lessons.Count); tip.SetActive(true); tip.transform.Find("Text").GetComponent <Text>().text = "提交成功"; }
protected void Button1_Click(object sender, EventArgs e) { lesson Lesson = new lesson(); }
public IList <exercis> GetExercisesByUserSingleLesson(lesson lesson) { return(_exerciseRepository.GetExercisesByUserSingleLesson(lesson)); }
protected void SaveSession() { using (var db = new CstwebEntities()) { lesson les = new lesson(); int temp; double cr; if (TxtLessonName.Text.Trim() != "") les.classname = TxtLessonName.Text.Trim(); temp = Convert.ToInt32(DDLClass.SelectedValue); les.lesscla = temp; try { if (TxtTeach.Text.Trim() != "") { temp = Convert.ToInt32(TxtTeach.Text.Trim()); les.teach = temp; } } catch { } try { if (TxtExp.Text.Trim() != "") { temp = Convert.ToInt32(TxtExp.Text.Trim()); les.experiment = temp; } } catch { } try { if (TxtCredits.Text.Trim() != "") { cr = Convert.ToDouble(TxtCredits.Text.Trim()); les.credits = cr; } } catch { } try { string tempstr = Server.HtmlDecode(myEditor.InnerHtml); if (tempstr.Trim() != "") { les.etc = tempstr; } } catch { } try { if (LblFilename.Text != "") { les.lesfile = LblFilename.Text; } } catch { } Session["Less"] = les; if (Label1.Text == "0") Session["First1"] = null; else Session["First1"] = Label1.Text; if (Label2.Text == "0") Session["First2"] = null; else Session["First2"] = Label2.Text; if (Label3.Text == "0") Session["First3"] = null; else Session["First3"] = Label3.Text; } }
protected void BtnPost_Click(object sender, EventArgs e) { int temp; double cr; if (IsOK()) { using (var db = new CstwebEntities()) { if (Session["lessonID"].ToString() != "0") { try { temp = Convert.ToInt32(Session["lessonID"].ToString()); var del = db.lesrelation.Where(a => a.lesson == temp).ToList(); lesrelation les1; try { les1 = del[0]; db.lesrelation.Remove(les1); db.SaveChanges(); } catch { } try { les1 = del[1]; db.lesrelation.Remove(les1); db.SaveChanges(); } catch { } try { les1 = del[2]; db.lesrelation.Remove(les1); db.SaveChanges(); } catch { } lesson les = db.lesson.First(a => a.id == temp); les.classname = TxtLessonName.Text.Trim(); cr = Convert.ToDouble(TxtCredits.Text.Trim()); les.credits = cr; temp = Convert.ToInt32(TxtTeach.Text.Trim()); les.teach = temp; temp = Convert.ToInt32(TxtExp.Text.Trim()); les.experiment = temp; temp = Convert.ToInt32(DDLClass.SelectedValue); les.lesscla = temp; temp = Convert.ToInt32(Session["lessonID"].ToString()); if (LblFilename.Text != "") { les.lesfile = LblFilename.Text; } string tempstr = Server.HtmlDecode(myEditor.InnerHtml); les.etc = tempstr.Trim(); les1 = new lesrelation(); les1.lesson = temp; db.SaveChanges(); if (Label1.Text != "0") { temp = Convert.ToInt32(Label1.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } if (Label2.Text != "0") { temp = Convert.ToInt32(Label2.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } if (Label3.Text != "0") { temp = Convert.ToInt32(Label3.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } Session["FList"] = null; Session["Less"] = null; Session["First1"] = null; Session["First2"] = null; Session["First3"] = null; Session["lessonID"] = null; Response.Write("<script language=javascript>alert('修改成功');window.location = 'lessons.aspx';</script>"); } catch { Response.Write("<script>alert('修改失败')</script>"); } } else { try { lesson les = new lesson(); lesrelation les1 = new lesrelation(); les.classname = TxtLessonName.Text.Trim(); cr = Convert.ToDouble(TxtCredits.Text.Trim()); les.credits = cr; temp = Convert.ToInt32(TxtTeach.Text.Trim()); les.teach = temp; temp = Convert.ToInt32(TxtExp.Text.Trim()); les.experiment = temp; temp = Convert.ToInt32(DDLClass.SelectedValue); les.lesscla = temp; temp = Convert.ToInt32(Session["lessonID"].ToString()); if (LblFilename.Text != "") { les.lesfile = LblFilename.Text; } string tempstr = Server.HtmlDecode(myEditor.InnerHtml); les.etc = tempstr.Trim(); db.lesson.Add(les); db.SaveChanges(); temp = db.lesson.First(a => a.classname == TxtLessonName.Text.Trim()).id; les1.lesson = temp; if (Label1.Text != "0") { temp = Convert.ToInt32(Label1.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } if (Label2.Text != "0") { temp = Convert.ToInt32(Label2.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } if (Label3.Text != "0") { temp = Convert.ToInt32(Label3.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } Session["FList"] = null; Session["Less"] = null; Session["First1"] = null; Session["First2"] = null; Session["First3"] = null; Session["lessonID"] = null; Response.Write("<script language=javascript>alert('添加成功');window.location = 'lessons.aspx';</script>"); } catch { Response.Write("<script>alert('添加失败')</script>"); } } } } }
protected void SaveSession() { using (var db = new CstwebEntities()) { lesson les = new lesson(); int temp; double cr; if (TxtLessonName.Text.Trim() != "") { les.classname = TxtLessonName.Text.Trim(); } temp = Convert.ToInt32(DDLClass.SelectedValue); les.lesscla = temp; try { if (TxtTeach.Text.Trim() != "") { temp = Convert.ToInt32(TxtTeach.Text.Trim()); les.teach = temp; } } catch { } try { if (TxtExp.Text.Trim() != "") { temp = Convert.ToInt32(TxtExp.Text.Trim()); les.experiment = temp; } } catch { } try { if (TxtCredits.Text.Trim() != "") { cr = Convert.ToDouble(TxtCredits.Text.Trim()); les.credits = cr; } } catch { } try { string tempstr = Server.HtmlDecode(myEditor.InnerHtml); if (tempstr.Trim() != "") { les.etc = tempstr; } } catch { } try { if (LblFilename.Text != "") { les.lesfile = LblFilename.Text; } } catch { } Session["Less"] = les; if (Label1.Text == "0") { Session["First1"] = null; } else { Session["First1"] = Label1.Text; } if (Label2.Text == "0") { Session["First2"] = null; } else { Session["First2"] = Label2.Text; } if (Label3.Text == "0") { Session["First3"] = null; } else { Session["First3"] = Label3.Text; } } }
protected void BtnPost_Click(object sender, EventArgs e) { int temp; double cr; if (IsOK()) { using (var db = new CstwebEntities()) { if (Session["lessonID"].ToString() != "0") { try { temp = Convert.ToInt32(Session["lessonID"].ToString()); var del = db.lesrelation.Where(a => a.lesson == temp).ToList(); lesrelation les1; try { les1 = del[0]; db.lesrelation.Remove(les1); db.SaveChanges(); } catch { } try { les1 = del[1]; db.lesrelation.Remove(les1); db.SaveChanges(); } catch { } try { les1 = del[2]; db.lesrelation.Remove(les1); db.SaveChanges(); } catch { } lesson les = db.lesson.First(a => a.id == temp); les.classname = TxtLessonName.Text.Trim(); cr = Convert.ToDouble(TxtCredits.Text.Trim()); les.credits = cr; temp = Convert.ToInt32(TxtTeach.Text.Trim()); les.teach = temp; temp = Convert.ToInt32(TxtExp.Text.Trim()); les.experiment = temp; temp = Convert.ToInt32(DDLClass.SelectedValue); les.lesscla = temp; temp = Convert.ToInt32(Session["lessonID"].ToString()); if (LblFilename.Text != "") { les.lesfile = LblFilename.Text; } string tempstr = Server.HtmlDecode(myEditor.InnerHtml); les.etc = tempstr.Trim(); les1 = new lesrelation(); les1.lesson = temp; db.SaveChanges(); if (Label1.Text != "0") { temp = Convert.ToInt32(Label1.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } if (Label2.Text != "0") { temp = Convert.ToInt32(Label2.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } if (Label3.Text != "0") { temp = Convert.ToInt32(Label3.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } Session["FList"] = null; Session["Less"] = null; Session["First1"] = null; Session["First2"] = null; Session["First3"] = null; Session["lessonID"] = null; Response.Write("<script language=javascript>alert('修改成功');window.location = 'lessons.aspx';</script>"); } catch { Response.Write("<script>alert('修改失败')</script>"); } } else { try { lesson les = new lesson(); lesrelation les1 = new lesrelation(); les.classname = TxtLessonName.Text.Trim(); cr = Convert.ToDouble(TxtCredits.Text.Trim()); les.credits = cr; temp = Convert.ToInt32(TxtTeach.Text.Trim()); les.teach = temp; temp = Convert.ToInt32(TxtExp.Text.Trim()); les.experiment = temp; temp = Convert.ToInt32(DDLClass.SelectedValue); les.lesscla = temp; temp = Convert.ToInt32(Session["lessonID"].ToString()); if (LblFilename.Text != "") { les.lesfile = LblFilename.Text; } string tempstr = Server.HtmlDecode(myEditor.InnerHtml); les.etc = tempstr.Trim(); db.lesson.Add(les); db.SaveChanges(); temp = db.lesson.First(a => a.classname == TxtLessonName.Text.Trim()).id; les1.lesson = temp; if (Label1.Text != "0") { temp = Convert.ToInt32(Label1.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } if (Label2.Text != "0") { temp = Convert.ToInt32(Label2.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } if (Label3.Text != "0") { temp = Convert.ToInt32(Label3.Text); les1.firstlesson = temp; db.lesrelation.Add(les1); db.SaveChanges(); } Session["FList"] = null; Session["Less"] = null; Session["First1"] = null; Session["First2"] = null; Session["First3"] = null; Session["lessonID"] = null; Response.Write("<script language=javascript>alert('添加成功');window.location = 'lessons.aspx';</script>"); } catch { Response.Write("<script>alert('添加失败')</script>"); } } } } }
private IEnumerable <List <TimeSuggestion> > GetTimeSlotsWithFreeClassooms(List <List <TimeSuggestion> > possibleTimeSlots, lesson lesson) { List <classroom> classrooms = new List <classroom>(); classrooms = _db.getAllClassRooms().Where(cr => cr.croomtype != null).Where(cr => cr.croomtype.idcroomtype == lesson.subject.type).ToList(); var classroomsTimeSlots = classrooms.Select(cr => new Pair(cr, GetLessonTimeSlotsForClassroom(cr))).ToList(); for (var day = 0; day < possibleTimeSlots.Count; ++day) { for (var timeSlot = 0; timeSlot < possibleTimeSlots.ElementAt(day).Count; timeSlot++) { foreach (var classroom in classroomsTimeSlots) { var cr = (classroom)classroom.First; var crTimeSlots = (List <List <TimeSlot> >)classroom.Second; var free = true; for (var start = 0; start < lesson.subject.time.GetValueOrDefault(); ++start) { if (crTimeSlots.ElementAt(day).ElementAt(timeSlot + start).Availability == Availability.NonAvailable) { free = false; } } if (free) { possibleTimeSlots.ElementAt(day).ElementAt(timeSlot).possibleClassrooms.Add(Converter.ConvertDbClassroomToClassroom(cr)); } } } } return(possibleTimeSlots.Select(day => day.Where(ts => ts.possibleClassrooms.Any()).ToList())); }
public IList <exercis> GetExercisesByUserSingleLesson(lesson lesson) { return(_context.exercises.Where(ex => ex.lesson_id == lesson.id).ToList()); }
public IList <int> GetDoneExercisesNumbersByLesson(lesson lesson) { return(_exerciseRepository.GetDoneExercisesNumbersByLessonId(lesson.id)); }