public ActionResult GetStudents() { StudentCore sCore = new StudentCore(); DataTable model = sCore.getAll(); return(View(model)); }
public FormStudent() : base() { this.gridStudent.Name = "gridStudent"; this.gridStudent.Dock = DockStyle.Top; // 添加 DataGridView 到窗口 this.Controls.AddRange(new Control[] { this.gridStudent }); // 添加 Student 表格到 DataSet this.dsStudent.Tables.Add("Student"); this.dsStudent.Tables["Student"].Columns.AddRange( new DataColumn[] { new DataColumn("Name"), new DataColumn("Age"), new DataColumn("ClassName") } ); // 创建 StudentCore StudentCore core = new StudentCore(this, new TableSetting <PagerSetting>[] { new TableSetting <PagerSetting>("Student", this.dsStudent.Tables["Student"], null, null, null) } ); // 绑定填充方法到窗口的 Load 事件 core.BindDataEvent <EventArgs> (this, "Load", EventHandlerType.EventHandler, DataActionType.Fill, "Student"); }
public void SetStudentGroupSingleGroup() { // Arrange var actual = new List <Student> { new Student() { GroupId = 0, Name = "Paul", TimeIndex = 0, MarkIndex = 1 }, new Student() { GroupId = 0, Name = "Fred", TimeIndex = 1, MarkIndex = 0 }, new Student() { GroupId = 0, Name = "John", TimeIndex = 2, MarkIndex = 1 } }; var expected = new List <Student> { new Student() { GroupId = 1, Name = "Paul", TimeIndex = 0, MarkIndex = 1 }, new Student() { GroupId = 1, Name = "Fred", TimeIndex = 1, MarkIndex = 0 }, new Student() { GroupId = 1, Name = "John", TimeIndex = 2, MarkIndex = 1 } }; // Act var logger = new Logger(); var studentCore = new StudentCore(logger); studentCore.SetStudentGroups(actual); // Assert CollectionAssert.AreEqual(expected, actual, new StudentComparer()); }
// GET: Student public virtual async Task <ActionResult> Index() { ViewBag.Subjects = await SubjectCore.GetAllAsync().ConfigureAwait(false); ViewBag.Student = await StudentCore.GetAllAsync().ConfigureAwait(false); var students = await StudentCore.GetAllAsync(new[] { nameof(Student.Subjects) }).ConfigureAwait(false); return(View(students)); }
public virtual async Task <ActionResult> Create(Student model) { try { await StudentCore.CreateAsync(model); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public void PostRequestBadRequest() { // Arrange var mockLogger = new Mock <ILogger>(); var studentCore = new StudentCore(mockLogger.Object); var controller = new StudentGroupsController(mockLogger.Object, studentCore); String[,] input = null; // Act var output = controller.Post(input); // Assert Assert.IsInstanceOfType(output, typeof(BadRequestResult)); }
public virtual async Task <ActionResult> Delete(Guid id, Student model) { try { // TODO: Add delete logic here await StudentCore.GetAsync(id); await StudentCore.DeleteAsync(model); return(RedirectToAction("Index")); } catch { return(View()); } }
public virtual async Task <ActionResult> Edit(Guid id, Student model) { await StudentCore.UpdateAsync(model); await StudentCore.GetAsync(id); try { // TODO: Add update logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public void PostRequestMultipleGroups() { // Arrange var mockLogger = new Mock <ILogger>(); var studentCore = new StudentCore(mockLogger.Object); var controller = new StudentGroupsController(mockLogger.Object, studentCore); var input = new String[, ] { { "", "Paul", "" }, { "Fred", "", "" }, { "", "", "John" } }; var expected = new string[, ] { { "Paul", "Fred" }, { "John", "" } }; // Act var actual = controller.Post(input); // Assert CollectionAssert.AreEqual(expected, actual); }
public void GetStudentsWithMultipleGroups() { // Arrange var input = new String[, ] { { "", "Paul", "" }, { "Fred", "", "" }, { "", "John", "" } }; var expected = new List <Student> { new Student() { GroupId = 0, Name = "Paul", TimeIndex = 0, MarkIndex = 1 }, new Student() { GroupId = 0, Name = "Fred", TimeIndex = 1, MarkIndex = 0 }, new Student() { GroupId = 0, Name = "John", TimeIndex = 2, MarkIndex = 1 } }; // Act var logger = new Logger(); var studentCore = new StudentCore(logger); var actual = studentCore.GetStudents(input); // Assert CollectionAssert.AreEqual(expected, actual, new StudentComparer()); }
public void GetOutputSingleGroup() { // Arrange var input = new List <Student> { new Student() { GroupId = 1, Name = "Paul", TimeIndex = 0, MarkIndex = 1 }, new Student() { GroupId = 1, Name = "Fred", TimeIndex = 1, MarkIndex = 0 }, new Student() { GroupId = 1, Name = "John", TimeIndex = 2, MarkIndex = 1 } }; var expected = new String[, ] { { "Paul", "Fred", "John" } }; // Act var logger = new Logger(); var studentCore = new StudentCore(logger); var actual = studentCore.GetOutput(input); // Assert CollectionAssert.AreEqual(expected, actual); }
public virtual async Task <ActionResult> Filter(Guid?SubjectId) { ViewBag.Subject = await SubjectCore.GetAllAsync().ConfigureAwait(false); ViewBag.AllStudents = await StudentCore.GetAllAsync().ConfigureAwait(false); var model = await SubjectCore.GetFiltered(navigationProperties : new[] { nameof(Subject.Students) }).ConfigureAwait(false); if (model == null) { return(View()); } if (SubjectId != null && SubjectId != Guid.Empty) { ViewBag.ShiftIdToOpenInDialog = SubjectId.Value; } ViewBag.SubjectList = model.EntityContainers.First().Data; ViewBag.TotalShiftsCount = model.TotalItems; return(View(model)); }
// GET: Student/Edit/5 public virtual async Task <ActionResult> Edit(Guid id) { var std = await StudentCore.GetAsync(id); return(View(std)); }