コード例 #1
0
        public void CreateNewTableGroup(TableGroupInDb newTableGroup)
        {
            var tableGroup = new TableGroup
            {
                Name      = newTableGroup.Name,
                TeacherId = newTableGroup.TeacherId
            };

            _tableGroupRepository.AddNewTableGroup(tableGroup);
        }
コード例 #2
0
        public IActionResult SubmitTableGroup(IFormCollection form)
        {
            //get the number of students in a group
            int numberOfStudents = Int32.Parse(form["numberOfStudents"]);

            int[] ids = new int[numberOfStudents];
            //get the students ids from the form
            for (int index = 1; index <= numberOfStudents; index++)
            {
                //start the id-s array from 0
                ids[index - 1] = Int32.Parse(form["selectedStudent" + index]);
            }

            //insert the data into the mock database
            MockDatabase mockDatabase = new MockDatabase();

            mockDatabase.CreateGroup(ids);

            // Send to service and persist in the db
            // Retrieve the session user
            var sessionUser = HttpContext.Session.GetObjectFromJson <TeacherModel>("LoggedUser");
            var teacherId   = Convert.ToInt32(sessionUser.Id);

            string groupName = form["groupNameInput"];

            if (!string.IsNullOrEmpty(groupName))
            {
                var newTableGroup = new TableGroupInDb
                {
                    Name      = groupName,
                    TeacherId = teacherId
                };

                // Create a table group
                _tableGroupService.CreateNewTableGroup(newTableGroup);
            }
            return(RedirectToAction("Index", "Home"));
        }