public void Get_timetable_by_id_test()
        {
            var         repo        = new TimeTableRepository(context);
            var         classRepo   = new ClassRepository(context);
            var         subjectRepo = new SubjectRepository(context);
            ClassEntity clazz       = new ClassEntity("GR1");

            classRepo.AddNew(clazz);
            SubjectEntity subject = new SubjectEntity("AM", "Analiza");

            subjectRepo.AddNew(subject);
            TimeTableEntity model  = new TimeTableEntity("poniedziałek", clazz, subject);
            TimeTableEntity model2 = new TimeTableEntity("wtorek", clazz, subject);

            repo.AddNew(model);
            repo.AddNew(model2);

            var result = repo.GetById(2);

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Id);
            Assert.AreEqual(model2.Class.Id, result.Class.Id);
            Assert.AreEqual(model2.Subject.Id, result.Subject.Id);
            Assert.AreEqual(model2.Day, result.Day);
        }
Exemplo n.º 2
0
        public void Get_presences_by_student_and_subject_test()
        {
            var         repo      = new PresenceRepository(this.context);
            var         studrepo  = new StudentRepository(this.context);
            var         timerepo  = new TimeTableRepository(this.context);
            var         classrepo = new ClassRepository(this.context);
            var         subrepo   = new SubjectRepository(this.context);
            ClassEntity clazz     = new ClassEntity("GR1");

            classrepo.AddNew(clazz);
            StudentEntity model = new StudentEntity("Aneta", "Dams", clazz, true);

            studrepo.AddNew(model);
            SubjectEntity subject = new SubjectEntity("AM", "Analiza Matematyczna");

            subrepo.AddNew(subject);
            TimeTableEntity timeTable = new TimeTableEntity("poniedziałek", clazz, subject);
            var             model1    = new PresenceEntity(model, subject, DateTime.Now.Date, true);
            var             model2    = new PresenceEntity(model, subject, DateTime.Now.Date.AddDays(2), true);

            repo.AddNew(model1);
            repo.AddNew(model2);

            var result = repo.GetAllByStudentAndSubject(model.Id, subject.Id);

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(model1.Id, result[0].Id);
            Assert.AreEqual(model2.Id, result[1].Id);
        }
        public void Delete_TimeTable_By_TimeTable()
        {
            string timeTableName = "Test TimeTable to Delete";

            // Add to database
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                TimeTableRepository timeTableRepository = new TimeTableRepository(ctx);
                timeTableRepository.Add(new TimeTable { Name = timeTableName });
                timeTableRepository.SaveChanges();
            }

            // Find and delete it
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                List<TimeTable> timeTables = ctx.TimeTables.Where(pier => pier.Name == timeTableName).ToList();
                Assert.AreEqual(1, timeTables.Count());

                TimeTableRepository timeTableRepository = new TimeTableRepository(ctx);
                timeTableRepository.Delete(timeTables[0]);
                timeTableRepository.SaveChanges();
            }

            // Check that nothing is there
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                List<TimeTable> timeTables = ctx.TimeTables.Where(pier => pier.Name == timeTableName).ToList();
                Assert.AreEqual(0, timeTables.Count());
            }
        }
Exemplo n.º 4
0
 public TimeTableController(TimeTableManager timeTableManager, TimeTableRepository timeTableRepository, SubjectRepository subjectRepository, FacultyRepository facultyRepository, ClassesRepository classesRepository, TimeTableViewModelValidator tableViewModelValidator)
 {
     _timeTableManager        = timeTableManager;
     _timeTableRepository     = timeTableRepository;
     _subjectRepository       = subjectRepository;
     _facultyRepository       = facultyRepository;
     _classesRepository       = classesRepository;
     _tableViewModelValidator = tableViewModelValidator;
 }
Exemplo n.º 5
0
 public TimeTableManager(TimeTableRepository timeTableRepository,
                         ClassesRepository classesRepository,
                         SubjectRepository subjectRepository,
                         FacultyRepository facultyRepository,
                         StudentRepository studentRepository)
 {
     _timeTableRepository = timeTableRepository;
     _classesRepository   = classesRepository;
     _subjectRepository   = subjectRepository;
     _facultyRepository   = facultyRepository;
     _studentRepository   = studentRepository;
 }
Exemplo n.º 6
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context = context;
     Payments = new PaymentRepository(context);
     StudentPaymentAndPeriods = new StudentPaymentAndPeriodRepository(context);
     Groups      = new GroupRepository(context);
     Student     = new StudentRepository(context);
     Branchs     = new BranchRepository(context);
     Levels      = new LevelRepository(context);
     TimeTables  = new TimeTableRepository(context);
     Attendances = new AttendanceRepository(context);
     Comments    = new CommentRepository(context);
 }
        public void Add_new_timetable_test()
        {
            var         repo        = new TimeTableRepository(context);
            var         classRepo   = new ClassRepository(context);
            var         subjectRepo = new SubjectRepository(context);
            ClassEntity clazz       = new ClassEntity("GR1");

            classRepo.AddNew(clazz);
            SubjectEntity subject = new SubjectEntity("AM", "Analiza");

            subjectRepo.AddNew(subject);
            TimeTableEntity model = new TimeTableEntity("poniedziałek", clazz, subject);

            repo.AddNew(model);
        }
        public void Add_TimeTable()
        {
            string timeTableName = "Test TimeTable to Add";

            // Add to database
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                TimeTableRepository timeTableRepository = new TimeTableRepository(ctx);
                timeTableRepository.Add(new TimeTable { Name = timeTableName });
                timeTableRepository.SaveChanges();
            }

            // Check that it is there
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                List<TimeTable> timeTables = ctx.TimeTables.Where(pier => pier.Name == timeTableName).ToList();
                Assert.AreEqual(1, timeTables.Count());
            }
        }
Exemplo n.º 9
0
        public void Add_new_presence_test()
        {
            var         repo      = new PresenceRepository(this.context);
            var         studrepo  = new StudentRepository(this.context);
            var         timerepo  = new TimeTableRepository(this.context);
            var         classrepo = new ClassRepository(this.context);
            var         subrepo   = new SubjectRepository(this.context);
            ClassEntity clazz     = new ClassEntity("GR1");

            classrepo.AddNew(clazz);
            StudentEntity model = new StudentEntity("Aneta", "Dams", clazz, true);

            studrepo.AddNew(model);
            SubjectEntity subject = new SubjectEntity("AM", "Analiza Matematyczna");

            subrepo.AddNew(subject);
            TimeTableEntity timeTable = new TimeTableEntity("poniedziałek", clazz, subject);
            var             model1    = new PresenceEntity(model, subject, DateTime.Now.Date, true);

            repo.AddNew(model1);
        }
Exemplo n.º 10
0
 public UnitOfWork()
 {
     _dbContext            = new ApplicationDbContext();
     Users                 = new UserRepository(_dbContext);
     Teachers              = new TeacherRepository(_dbContext);
     Students              = new StudentRepository(_dbContext);
     Courses               = new CourseRepository(_dbContext);
     Rooms                 = new RoomRepository(_dbContext);
     Campuses              = new CampusRepository(_dbContext);
     Attendances           = new AttendanceRepository(_dbContext);
     StatusAttendances     = new StatusAttendanceRepository(_dbContext);
     StatusTimeTables      = new StatusTimeTableRepository(_dbContext);
     TimeSlots             = new TimeSlotRepository(_dbContext);
     TimeTables            = new TimeTableRepository(_dbContext);
     StudentGroups         = new StudentGroupRepository(_dbContext);
     StatusTakeAttendances = new StatusTakeAttendanceRepository(_dbContext);
     StudentFaces          = new StudentFacesRepository(_dbContext);
     IdentityStudents      = new IdentityStudentRepository(_dbContext);
     RecognitionImages     = new RecognitionImageRepository(_dbContext);
     Messages              = new MessageRepository(_dbContext);
     StatusesMessage       = new StatusMessageRepository(_dbContext);
 }
Exemplo n.º 11
0
        public void Get_all_timetables_by_class_test()
        {
            var         repo        = new TimeTableRepository(context);
            var         classRepo   = new ClassRepository(context);
            var         subjectRepo = new SubjectRepository(context);
            ClassEntity clazz       = new ClassEntity("GR1");
            ClassEntity clazz2      = new ClassEntity("GR2");

            classRepo.AddNew(clazz);
            classRepo.AddNew(clazz2);
            SubjectEntity subject = new SubjectEntity("AM", "Analiza");

            subjectRepo.AddNew(subject);
            TimeTableEntity model  = new TimeTableEntity("poniedziałek", clazz2, subject);
            TimeTableEntity model2 = new TimeTableEntity("wtorek", clazz, subject);

            repo.AddNew(model);
            repo.AddNew(model2);

            var result = repo.GetAllByClass("GR1");

            Assert.IsNotNull(result);
            Assert.AreEqual("GR1", result[0].Class.Id);
        }
Exemplo n.º 12
0
        private void LoadRepositories()
        {
            userRepository = new UserRepository(new CSVStream <User>(userFile, new UserConverter()), new ComplexSequencer());
            // USER OK


            roomRepository = new RoomRepository(new CSVStream <Room>(roomFile, new RoomConverter()), new LongSequencer());
            // ROOM OK

            inventoryItemRepository = new InventoryItemRepository(new CSVStream <InventoryItem>(inventoryItemFile, new InventoryItemConverter()), new LongSequencer(), roomRepository);

            timeTableRepository = new TimeTableRepository(new CSVStream <TimeTable>(timeTableFile, new TimeTableConverter()), new LongSequencer());
            // TIMETABLE OK
            hospitalRepository = new HospitalRepository(new CSVStream <Hospital>(hospitalFile, new HospitalConverter()), new LongSequencer(), roomRepository);
            // HOSPITAL OK

            secretaryRepository = new SecretaryRepository(new CSVStream <Secretary>(secretaryFile, new SecretaryConverter()), new ComplexSequencer(), timeTableRepository, hospitalRepository, userRepository);
            // SECRETARY OK
            managerRepository = new ManagerRepository(new CSVStream <Manager>(managerFile, new ManagerConverter()), new ComplexSequencer(), timeTableRepository, hospitalRepository, userRepository);
            // MANAGER OK
            doctorRepository = new DoctorRepository(new CSVStream <Doctor>(doctorFile, new DoctorConverter()), new ComplexSequencer(), timeTableRepository, hospitalRepository, roomRepository, userRepository);
            // DOCTOR OK
            patientRepository = new PatientRepository(new CSVStream <Patient>(patientFile, new PatientConverter()), new ComplexSequencer(), doctorRepository, userRepository);
            // PATIENT OK



            hospitalRepository.DoctorRepository    = doctorRepository;
            hospitalRepository.ManagerRepository   = managerRepository;
            hospitalRepository.SecretaryRepository = secretaryRepository;


            //Misc repositories
            locationRepository = new LocationRepository(new CSVStream <Location>(locationFile, new LocationConverter()), new LongSequencer());
            // LOCATION OK
            notificationRepository = new NotificationRepository(new CSVStream <Notification>(notificationFile, new NotificationConverter()), new LongSequencer(), patientRepository, doctorRepository, managerRepository, secretaryRepository);
            // NOTIFICATION OK
            messageRepository = new MessageRepository(new CSVStream <Message>(messageFile, new MessageConverter()), new LongSequencer(), patientRepository, doctorRepository, managerRepository, secretaryRepository);
            // MESSAGE OK
            articleRepository = new ArticleRepository(new CSVStream <Article>(articleFile, new ArticleConverter()), new LongSequencer(), doctorRepository, managerRepository, secretaryRepository);
            //ARTICLE OK
            questionRepository = new QuestionRepository(new CSVStream <Question>(questionFile, new QuestionConverter()), new LongSequencer());
            // QUESTION OK
            doctorQuestionRepository = new QuestionRepository(new CSVStream <Question>(doctorQuestionFile, new QuestionConverter()), new LongSequencer());
            //DOCTOR QUESTION OK
            feedbackRepository       = new FeedbackRepository(new CSVStream <Feedback>(feedbackFile, new FeedbackConverter()), new LongSequencer(), questionRepository, patientRepository, doctorRepository, managerRepository, secretaryRepository);
            doctorFeedbackRepository = new DoctorFeedbackRepository(new CSVStream <DoctorFeedback>(doctorFeedbackFile, new DoctorFeedbackConverter()), new LongSequencer(), doctorQuestionRepository, patientRepository, doctorRepository);


            //Hospital management repositories
            symptomRepository = new SymptomRepository(new CSVStream <Symptom>(symptomsFile, new SymptomConverter()), new LongSequencer());
            //SYMPTOM REPO OK
            diseaseRepository = new DiseaseRepository(new CSVStream <Disease>(diseaseFile, new DiseaseConverter()), new LongSequencer(), medicineRepository, symptomRepository);
            //DISEASE REPO OK
            ingredientRepository = new IngredientRepository(new CSVStream <Ingredient>(ingredientFile, new IngredientConverter()), new LongSequencer());
            //INGREDIENT REPO OK
            medicineRepository = new MedicineRepository(new CSVStream <Medicine>(medicineFile, new MedicineConverter()), new LongSequencer(), ingredientRepository, diseaseRepository);
            //MEDICINE REPO OK


            prescriptionRepository = new PrescriptionRepository(new CSVStream <Prescription>(prescriptionFile, new PrescriptionConverter()), new LongSequencer(), doctorRepository, medicineRepository);
            //PRESCRIPTION REPO OK

            //Medical repositories

            allergyRepository = new AllergyRepository(new CSVStream <Allergy>(allergyFile, new AllergyConverter()), new LongSequencer(), ingredientRepository, symptomRepository);
            //ALLERGY REPO OK

            appointmentRepository = new AppointmentRepository(new CSVStream <Appointment>(appointmentsFile, new AppointmentConverter()), new LongSequencer(), patientRepository, doctorRepository, roomRepository);
            //GERGO REPO OK?
            therapyRepository = new TherapyRepository(new CSVStream <Therapy>(therapyFile, new TherapyConverter()), new LongSequencer(), medicalRecordRepository, medicalRecordRepository, prescriptionRepository, diagnosisRepository);

            //med record
            medicalRecordRepository = new MedicalRecordRepository(new CSVStream <MedicalRecord>(medicalRecordFile, new MedicalRecordConverter()), new LongSequencer(), patientRepository, diagnosisRepository, allergyRepository);
            //u medical record moras da set diagnosis repo
            diagnosisRepository = new DiagnosisRepository(new CSVStream <Diagnosis>(diagnosisFile, new DiagnosisConverter()), new LongSequencer(), therapyRepository, diseaseRepository, medicalRecordRepository);
            //therapy
            // therapyRepository = new TherapyRepository(new CSVStream<Therapy>(therapyFile,new TherapyConverter()),new LongSequencer(),medicalRecordRepository, )

            diseaseRepository.MedicineEagerCSVRepository = medicineRepository;
            medicineRepository.DiseaseRepository         = diseaseRepository;

            medicalRecordRepository.DiagnosisRepository       = diagnosisRepository;
            diagnosisRepository.MedicalRecordRepository       = medicalRecordRepository;
            diagnosisRepository.TherapyEagerCSVRepository     = therapyRepository;
            therapyRepository.DiagnosisCSVRepository          = diagnosisRepository;
            therapyRepository.MedicalRecordRepository         = medicalRecordRepository;
            therapyRepository.MedicalRecordEagerCSVRepository = medicalRecordRepository;



            //ODAVDDE RADITI OSTALE

            doctorStatisticRepository = new DoctorStatisticRepository(new CSVStream <StatsDoctor>(doctorStatisticsFile, new DoctorStatisticsConverter(",")), new LongSequencer(), doctorRepository);
            // Doc Stats OK

            inventoryStatisticRepository = new InventoryStatisticsRepository(new CSVStream <StatsInventory>(inventoryStatisticsFile, new InventoryStatisticsConverter(",")), new LongSequencer(), medicineRepository, inventoryItemRepository);
            // InventoryStats OK

            roomStatisticRepository = new RoomStatisticsRepository(new CSVStream <StatsRoom>(roomStatisticsFile, new RoomStatisticsConverter(",")), new LongSequencer(), roomRepository);
            // RoomStats OK

            inventoryRepository = new InventoryRepository(new CSVStream <Inventory>(inventoryFile, new InventoryConverter(",", ";")), new LongSequencer(), inventoryItemRepository, medicineRepository);
        }
        public void Update_TimeTable()
        {
            string timeTableName = "Test TimeTable to Update";
            string timeTableNameUpdated = "Test TimeTable Updated";

            // Add to database
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                TimeTableRepository timeTableRepository = new TimeTableRepository(ctx);
                timeTableRepository.Add(new TimeTable { Name = timeTableName });
                timeTableRepository.SaveChanges();
            }

            // Find and update it
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                List<TimeTable> timeTables = ctx.TimeTables.Where(pier => pier.Name == timeTableName).ToList();
                Assert.AreEqual(1, timeTables.Count());

                TimeTableRepository timeTableRepository = new TimeTableRepository(ctx);
                timeTables[0].Name = timeTableNameUpdated;
                timeTableRepository.Update(timeTables[0]);
                timeTableRepository.SaveChanges();
            }

            // Check that the new name is there
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                List<TimeTable> timeTables = ctx.TimeTables.Where(pier => pier.Name == timeTableNameUpdated).ToList();
                Assert.AreEqual(1, timeTables.Count());
            }
        }