Example #1
0
        public ActionResult  GetStudents()
        {
            StudentCore sCore = new StudentCore();
            DataTable   model = sCore.getAll();

            return(View(model));
        }
Example #2
0
            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");
            }
Example #3
0
        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());
        }
Example #4
0
        // 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));
        }
Example #5
0
        public virtual async Task <ActionResult> Create(Student model)
        {
            try
            {
                await StudentCore.CreateAsync(model);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Example #6
0
        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));
        }
Example #7
0
        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());
            }
        }
Example #8
0
        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());
            }
        }
Example #9
0
        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);
        }
Example #10
0
        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());
        }
Example #11
0
        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);
        }
Example #12
0
        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));
        }
Example #13
0
        // GET: Student/Edit/5
        public virtual async Task <ActionResult> Edit(Guid id)
        {
            var std = await StudentCore.GetAsync(id);

            return(View(std));
        }