コード例 #1
0
        public AssignmentTracker PostGrade(AssignmentTracker at)
        {
            AssignmentTrackerRepo repo = new AssignmentTrackerRepo();

            if (at.Id == 0)
            {
                repo.Insert(at);
            }
            else
            {
                repo.Update(at);
            }
            return(at);
        }
コード例 #2
0
        protected override void Seed(ApplicationDbContext context)
        {
            // Don't want to redo this multiple times, only if we drop the database and need to re-seed
            if (new UserProfileRepo().GetAll().Any())
            {
                return;
            }

            CreateRole(context, "Admin");
            CreateRole(context, "Parent");
            CreateRole(context, "Student");
            CreateRole(context, "Teacher");

            string fakeTeacherId = CreateUser(context, "*****@*****.**", "password123", "Test", "Teacher", "Teacher", null);
            string fakeStudentId = CreateUser(context, "*****@*****.**", "password123", "Test", "Student", "Student", null);
            string fakeParentId  = CreateUser(context, "*****@*****.**", "password123", "Test", "Parent", "Parent", null);

            ParentStudentRepository psRepo = new ParentStudentRepository();

            psRepo.Add(fakeParentId, fakeStudentId);

            var algebra = new Course()
            {
                TeacherId         = fakeTeacherId,
                Name              = "Algebra 1",
                Department        = "Math",
                CourseDescription = "Math and math related stuff",
                StartDate         = DateTime.Today,
                EndDate           = DateTime.Today.AddDays(90)
            };

            var history = new Course()
            {
                TeacherId         = fakeTeacherId,
                Name              = "America",
                Department        = "Social Studies",
                CourseDescription = "lots of old people",
                StartDate         = DateTime.Today,
                EndDate           = DateTime.Today.AddDays(90)
            };

            CourseRepository      cRepo  = new CourseRepository();
            RosterRepository      rRepo  = new RosterRepository();
            AssignmentRepository  aRepo  = new AssignmentRepository();
            AssignmentTrackerRepo atRepo = new AssignmentTrackerRepo();

            cRepo.Insert(algebra);
            cRepo.Insert(history);

            List <string> moreStudentsIds = new List <string>();

            for (int i = 0; i < 50; i++)
            {
                string newStudentId = CreateUser(context, "fakestudent." + i + "@test.com", "password123", "Fake", "Student" + i, "Student", i % 13);
                moreStudentsIds.Add(newStudentId);

                if (i % 10 == 0)
                {
                    rRepo.Insert(new Roster()
                    {
                        CourseId = history.CourseId, IsActive = true, UserId = newStudentId
                    });
                }

                if (i % 8 == 0)
                {
                    rRepo.Insert(new Roster()
                    {
                        CourseId = algebra.CourseId, IsActive = true, UserId = newStudentId
                    });
                }
            }

            var rosterInfo = new Roster
            {
                CourseId = algebra.CourseId,
                UserId   = fakeStudentId,
                IsActive = true
            };

            rRepo.Insert(rosterInfo);

            var assignment = new Assignment
            {
                AssignmentDescription = "First Assignment Description",
                CourseId       = algebra.CourseId,
                DueDate        = DateTime.Now.AddDays(90),
                Name           = "First Assignment",
                PointsPossible = 45
            };

            aRepo.Insert(assignment);

            var assignment2 = new Assignment
            {
                AssignmentDescription = "Second Assignment Description",
                CourseId       = algebra.CourseId,
                DueDate        = DateTime.Now.AddDays(90),
                Name           = "Second Assignment",
                PointsPossible = 50
            };

            aRepo.Insert(assignment2);

            var grade = new AssignmentTracker
            {
                AssignmentId = assignment.AssignmentId,
                EarnedPoints = 40,
                RosterId     = rosterInfo.RosterId
            };

            atRepo.Insert(grade);

            var grade2 = new AssignmentTracker
            {
                AssignmentId = assignment2.AssignmentId,
                EarnedPoints = 47,
                RosterId     = rosterInfo.RosterId
            };

            atRepo.Insert(grade2);
        }
コード例 #3
0
        public AssignmentTracker GetGrade(int id)
        {
            AssignmentTrackerRepo repo = new AssignmentTrackerRepo();

            return(repo.GetById(id));
        }