public async Task <bool> Create(StudentTerm studentTerm)
        {
            StudentTermDAO studentTermDAO = examRegContext.StudentTerm
                                            .Where(s => (s.StudentId.Equals(studentTerm.StudentId) && s.TermId.Equals(studentTerm.TermId)))
                                            .FirstOrDefault();

            if (studentTermDAO == null)
            {
                studentTermDAO = new StudentTermDAO()
                {
                    StudentId   = studentTerm.StudentId,
                    TermId      = studentTerm.TermId,
                    IsQualified = studentTerm.IsQualified
                };

                await examRegContext.StudentTerm.AddAsync(studentTermDAO);
            }
            else
            {
                studentTermDAO.IsQualified = studentTerm.IsQualified;
            };
            await examRegContext.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> Create(ExamRoom examRoom)
        {
            ExamRoomDAO examRoomDAO = examRegContext.ExamRoom.Where(e => e.Id.Equals(examRoom.Id)).FirstOrDefault();

            if (examRoomDAO == null)
            {
                examRoomDAO = new ExamRoomDAO()
                {
                    Id = examRoom.Id,
                    AmphitheaterName = examRoom.AmphitheaterName,
                    ComputerNumber   = examRoom.ComputerNumber,
                    RoomNumber       = examRoom.RoomNumber
                };
                await examRegContext.ExamRoom.AddAsync(examRoomDAO);
            }
            else
            {
                examRoomDAO.Id = examRoom.Id;
                examRoomDAO.AmphitheaterName = examRoom.AmphitheaterName;
                examRoomDAO.ComputerNumber   = examRoom.ComputerNumber;
                examRoomDAO.RoomNumber       = examRoom.RoomNumber;
            };

            await examRegContext.SaveChangesAsync();

            return(true);
        }
Example #3
0
        public async Task <bool> Create(Semester semester)
        {
            SemesterDAO semesterDAO = examRegContext.Semester.Where(s => s.Id.Equals(semester.Id)).FirstOrDefault();

            if (semesterDAO == null)
            {
                semesterDAO = new SemesterDAO()
                {
                    Id          = semester.Id,
                    StartYear   = semester.StartYear,
                    EndYear     = semester.EndYear,
                    IsFirstHalf = semester.IsFirstHalf
                };

                await examRegContext.Semester.AddAsync(semesterDAO);
            }
            else
            {
                semesterDAO.StartYear   = semester.StartYear;
                semesterDAO.EndYear     = semester.EndYear;
                semesterDAO.IsFirstHalf = semester.IsFirstHalf;
            };
            await examRegContext.SaveChangesAsync();

            return(true);
        }
Example #4
0
        public async Task <bool> Create(Student student)
        {
            StudentDAO studentDAO = examRegContext.Student.Where(s => s.Id.Equals(student.Id)).FirstOrDefault();

            if (studentDAO == null)
            {
                studentDAO = new StudentDAO()
                {
                    Id            = student.Id,
                    StudentNumber = student.StudentNumber,
                    LastName      = student.LastName,
                    GivenName     = student.GivenName,
                    Birthday      = student.Birthday,
                    Email         = student.Email
                };
                await examRegContext.Student.AddAsync(studentDAO);
            }
            else
            {
                studentDAO.StudentNumber = student.StudentNumber;
                studentDAO.LastName      = student.LastName;
                studentDAO.GivenName     = student.GivenName;
                studentDAO.Birthday      = student.Birthday;
                studentDAO.Email         = student.Email;
            };

            await examRegContext.SaveChangesAsync();

            return(true);
        }
Example #5
0
        public async Task <bool> Create(ExamRoomExamPeriod examRoomExamPeriod)
        {
            ExamRoomExamPeriodDAO examRoomExamPeriodDAO = examRegContext.ExamRoomExamPeriod
                                                          .Where(s => (s.ExamRoomId.Equals(examRoomExamPeriod.ExamRoomId) && s.ExamPeriodId.Equals(examRoomExamPeriod.ExamPeriodId)))
                                                          .FirstOrDefault();

            if (examRoomExamPeriodDAO == null)
            {
                examRoomExamPeriodDAO = new ExamRoomExamPeriodDAO()
                {
                    ExamRoomId   = examRoomExamPeriod.ExamRoomId,
                    ExamPeriodId = examRoomExamPeriod.ExamPeriodId
                };

                await examRegContext.ExamRoomExamPeriod.AddAsync(examRoomExamPeriodDAO);
            }
            else
            {
                examRoomExamPeriodDAO.ExamRoomId   = examRoomExamPeriod.ExamRoomId;
                examRoomExamPeriodDAO.ExamPeriodId = examRoomExamPeriod.ExamPeriodId;
            };
            await examRegContext.SaveChangesAsync();

            return(true);
        }
Example #6
0
        public async Task <bool> Create(Term term)
        {
            TermDAO termDAO = examRegContext.Term
                              .Where(t => t.Id.Equals(term.Id))
                              .FirstOrDefault();

            if (termDAO == null)
            {
                termDAO = new TermDAO()
                {
                    Id          = term.Id,
                    SubjectName = term.SubjectName,
                    SemesterId  = term.SemesterId
                };
                await examRegContext.Term.AddAsync(termDAO);
            }
            else
            {
                termDAO.Id          = term.Id;
                termDAO.SubjectName = term.SubjectName;
                termDAO.SemesterId  = term.SemesterId;
            };

            await examRegContext.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> Create(User user)
        {
            examRegContext.User.Add(new UserDAO
            {
                Id        = user.Id,
                Username  = user.Username,
                Password  = user.Password,
                IsAdmin   = user.IsAdmin,
                StudentId = user.StudentId
            });
            await examRegContext.SaveChangesAsync();

            return(true);
        }
Example #8
0
        public async Task <bool> Create(ExamProgram examProgram)
        {
            ExamProgramDAO examProgramDAO = new ExamProgramDAO()
            {
                Id         = examProgram.Id,
                Name       = examProgram.Name,
                SemesterId = examProgram.SemesterId,
                IsCurrent  = false
            };
            await examRegContext.ExamProgram.AddAsync(examProgramDAO);

            await examRegContext.SaveChangesAsync();

            return(true);
        }
Example #9
0
        public async Task <bool> Create(ExamPeriod examPeriod)
        {
            ExamPeriodDAO examPeriodDAO = new ExamPeriodDAO()
            {
                Id            = examPeriod.Id,
                ExamDate      = examPeriod.ExamDate,
                StartHour     = examPeriod.StartHour,
                FinishHour    = examPeriod.FinishHour,
                TermId        = examPeriod.TermId,
                ExamProgramId = examPeriod.ExamProgramId
            };
            await examRegContext.ExamPeriod.AddAsync(examPeriodDAO);

            await examRegContext.SaveChangesAsync();

            return(true);
        }
Example #10
0
        public async Task <bool> Create(ExamRegister examRegister)
        {
            ExamRegisterDAO newExamRegisterDAO = new ExamRegisterDAO
            {
                ExamPeriodId = examRegister.ExamPeriodId,
                StudentId    = examRegister.StudentId,
                ExamRoomId   = examRegister.ExamRoomId
            };

            examRegContext.ExamRegister.Add(newExamRegisterDAO);
            await examRegContext.SaveChangesAsync();

            return(true);
        }