public static SeatingChartInfo Create(SeatingChart seatingChart) { var res = new SeatingChartInfo { Columns = seatingChart.Columns, Rows = seatingChart.Rows, ClassId = seatingChart.SectionId, SeatingList = new List <IList <SeatInfo> >() }; var index = 0; for (byte row = 1; row <= res.Rows; row++) { var seats = new List <SeatInfo>(); for (byte column = 1; column <= res.Columns; column++) { var seatInfo = new SeatInfo { Row = row, Column = column, Index = index }; var seat = seatingChart.Seats.FirstOrDefault(x => x.Column == column && x.Row == row); if (seat != null) { seatInfo.StudentId = seat.StudentId; } seats.Add(seatInfo); index++; } res.SeatingList.Add(seats); } return(res); }
public ActionResult DeleteConfirmed(int id) { SeatingChart seatingChart = db.SeatingCharts.Find(id); db.SeatingCharts.Remove(seatingChart); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,SeatingID,Email")] SeatingChart seatingChart) { if (ModelState.IsValid) { db.Entry(seatingChart).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(seatingChart)); }
public int GetSolution2(String path) { var seatChart = new SeatingChart(path); while (seatChart.Update(SeatFinder.Visible, 5) != 0) { } return(seatChart.CountOccupiedSeats()); }
public ActionResult Create([Bind(Include = "ID,FirstName,LastName,SeatingID,Email")] SeatingChart seatingChart) { if (ModelState.IsValid) { db.SeatingCharts.Add(seatingChart); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(seatingChart)); }
public void SeatingChartTest() { SeatingChart Chart = new SeatingChart(1, 1); List <Seat> Expected = new List <Seat>(); Expected.Add(new Seat(1, "A")); Assert.AreEqual(Chart.SeatList[0].ToString(), Expected[0].ToString()); }
// GET: SeatingCharts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SeatingChart seatingChart = db.SeatingCharts.Find(id); if (seatingChart == null) { return(HttpNotFound()); } return(View(seatingChart)); }
protected void LoadTable() { Dictionary <String, int> map = MorningMeetingSeatClicker.MapMarkingToGradeTableEntry(); Dictionary <int, String> revmap = new Dictionary <int, string>(); foreach (String key in map.Keys) { revmap.Add(map[key], key); } using (WebhostEntities db = new WebhostEntities()) { int mmid = AttendanceControl.MorningMeetingSectionId(); Section morningmeeting = db.Sections.Where(sec => sec.id == mmid).Single(); if (morningmeeting.SeatingCharts.Count <= 0) { MailControler.MailToUser("Morning Meeting Seating Chart.", AttendanceControl.GenerateMorningMeetingSeatingChart(), ((BasePage)Page).user); } String rows = "ABCDEFGHIJKL"; SeatingChart chart = db.Sections.Where(sec => sec.id == mmid).Single().SeatingCharts.ToList().First(); foreach (SeatingChartSeat seat in chart.SeatingChartSeats.Where(s => s.StudentId.HasValue).ToList()) { String id = String.Format("{0}{1}", rows[seat.Row], seat.Column + 1); seatControls.Where(sc => sc.ID.Equals(id)).Single().StudentId = seat.StudentId.Value; seatControls.Where(sc => sc.ID.Equals(id)).Single().ToolTip = String.Format("{0} {1}", seat.Student.FirstName, seat.Student.LastName); if (morningmeeting.AttendanceMarkings.Where(mk => mk.AttendanceDate.Equals(SelectedDate) && mk.StudentID == seat.StudentId.Value).Count() > 0) { seatControls.Where(sc => sc.ID.Equals(id)).Single().Marking = revmap[morningmeeting.AttendanceMarkings.Where(mk => mk.AttendanceDate.Equals(SelectedDate) && mk.StudentID == seat.StudentId.Value).Single().MarkingIndex]; } else { seatControls.Where(sc => sc.ID.Equals(id)).Single().Marking = "OK"; } } foreach (MorningMeetingSeatClicker clicker in seatControls) { clicker.Enabled = clicker.StudentId != -1; } } }
public void UpdateSeatingChart(int classId, int markingPeriodId, SeatingChartInfo seatingChartInfo) { var seatingChart = new SeatingChart { Columns = seatingChartInfo.Columns, Rows = seatingChartInfo.Rows, SectionId = classId, }; var stiSeats = new List <Seat>(); var students = ServiceLocator.StudentService.GetClassStudents(classId, markingPeriodId); var defaultStudent = students.FirstOrDefault(x => seatingChartInfo.SeatingList.All(y => y.All(z => z.StudentId != x.Id))); if (defaultStudent == null) { defaultStudent = students.First(); } foreach (var seats in seatingChartInfo.SeatingList) { foreach (var seatInfo in seats) { var seat = new Seat(); if (seatInfo.StudentId.HasValue) { seat.Column = seatInfo.Column; seat.Row = seatInfo.Row; seat.StudentId = seatInfo.StudentId.Value; } else { seat.StudentId = defaultStudent.Id; } stiSeats.Add(seat); } } seatingChart.Seats = stiSeats; SeatingChartStorage.UpdateChart(classId, markingPeriodId, seatingChart); }
public void AddSeatingChart(int mpId, int classId, SeatingChart chart) { chart.SectionId = classId; SeatingChartStorage.Add(new KeyValuePair <int, SeatingChart>(mpId, chart)); }
public void UpdateChart(int sectionId, int termId, SeatingChart chart) { Post(string.Format(urlFormat, sectionId, termId), chart, null, HttpMethod.Put); }