Example #1
0
        public void SetupStandardOptionsTable()
        {
            _databaseConnection = new SqlConnection(_databaseService.WebConfiguration.SqlConnectionString);
            _unitOfWork         = new UnitOfWork(_databaseConnection);
            _repository         = new StandardRepository(_unitOfWork);

            _options   = GetListOfOptions();
            _standards = GetListOfStandardVersions();

            StandardOptionsHandler.InsertRecords(_options);
            StandardsHandler.InsertRecords(_standards);

            _expectedStandardResult = new StandardOptions
            {
                StandardUId       = "ST0001_1.1",
                StandardReference = "ST0001",
                StandardCode      = 1,
                Version           = "1.1",
                CourseOption      = new List <string>
                {
                    "ST0001_1.1 Option 1",
                    "ST0001_1.1 Option 2"
                }
            };
        }
        public UnitOfWork(ApplicationDbContext context)
        {
            _context = context;

            Attempts       = new AttemptRepository(_context);
            Exams          = new ExamRepository(_context);
            Images         = new ImageRepository(_context);
            NoteParameters = new NoteParameterRepository(_context);
            Notifications  = new NotificationRepository(_context);
            Notes          = new NoteRepository(_context);
            Opinions       = new OpinionRepository(_context);
            Options        = new OptionRepository(_context);
            Passages       = new PassageRepository(_context);
            Questions      = new QuestionRepository(_context);
            Requirements   = new RequirementRepository(_context);
            Roles          = new RoleRepository(_context);
            RoleClaims     = new RoleClaimRepository(_context);
            Standards      = new StandardRepository(_context);
            Sittings       = new SittingRepository(_context);
            Topics         = new TopicRepository(_context);
            Users          = new UserRepository(_context);
            UserClaims     = new UserClaimRepository(_context);
            UserLogins     = new UserLoginRepository(_context);
            UserRoles      = new UserRoleRepository(_context);
            UserTokens     = new UserTokenRepository(_context);
        }
Example #3
0
        public void SetupStandardsTable()
        {
            _databaseConnection = new SqlConnection(_databaseService.WebConfiguration.SqlConnectionString);
            _unitOfWork         = new UnitOfWork(_databaseConnection);
            _repository         = new StandardRepository(_unitOfWork);

            _standards = GetListOfStandardVersions();

            StandardsHandler.InsertRecords(_standards);
        }
 public StudentBusinessLogic()
 {
     _StudentRepository                = S360RepositoryFactory.GetRepository("STUDENT") as StudentRepository;
     _SectionRepository                = S360RepositoryFactory.GetRepository("SECTION") as SectionRepository;
     _Standardpository                 = S360RepositoryFactory.GetRepository("STANDARD") as StandardRepository;
     _LanguageRepository               = S360RepositoryFactory.GetRepository("LANGUAGE") as LanguageRepository;
     _StudentCategoryRepository        = S360RepositoryFactory.GetRepository("STUDENTCATEGORY") as StudentCategoryRepository;
     _ReligionRepository               = S360RepositoryFactory.GetRepository("RELIGION") as ReligionRepository;
     _StudentAcademicRepository        = S360RepositoryFactory.GetRepository("STUDENTACADEMIC") as StudentAcademicRepository;
     _studentDetainPromotionRepository = S360RepositoryFactory.GetRepository("DETAINORPROMOTION") as StudentDetainPromotionRepository;
     _studentTCRepository              = S360RepositoryFactory.GetRepository("STUDENTTC") as StudentTCRepository;
 }
Example #5
0
        public IHttpActionResult GetSTANDARD_SELECTION()
        {
            try
            {
                int asssessmentId = Auth.AssessmentForUser();

                TinyMapper.Bind <STANDARD_SELECTION, Sals>();
                TinyMapper.Bind <Sals, STANDARD_SELECTION>();

                STANDARD_SELECTION sTANDARD_SELECTION = db.STANDARD_SELECTION.Find(asssessmentId);
                Sals rsal;
                if (sTANDARD_SELECTION == null)
                {
                    rsal = new Sals()
                    {
                        Selected_Sal_Level          = "Low",
                        Last_Sal_Determination_Type = "Simple",
                        CLevel = "Low",
                        ALevel = "Low",
                        ILevel = "Low"
                    };
                    sTANDARD_SELECTION = TinyMapper.Map <STANDARD_SELECTION>(rsal);
                    sTANDARD_SELECTION.Assessment_Id    = asssessmentId;
                    sTANDARD_SELECTION.Application_Mode = AssessmentModeData.DetermineDefaultApplicationMode();
                    db.STANDARD_SELECTION.Add(sTANDARD_SELECTION);
                    db.SaveChanges();
                }
                else
                {
                    rsal = TinyMapper.Map <Sals>(sTANDARD_SELECTION);
                }

                LevelManager lm = new LevelManager(asssessmentId, db);
                lm.RetrieveOtherLevels(rsal);
                StandardRepository sr = new StandardRepository(asssessmentId, lm, new StandardManager(), new AssessmentModeData(db, asssessmentId), new StandardSpecficLevelRepository(db));
                sr.Confidence_Level   = rsal.CLevel;
                sr.Integrity_Level    = rsal.ILevel;
                sr.Availability_Level = rsal.ALevel;
                //if(!rsal.SelectedSALOverride)
                //   rsal.Selected_Sal_Level = sr.Selected_Sal_Level;

                return(Ok(rsal));
            }
            catch (Exception)
            {
                return(Conflict());
                //return (HttpResponseMessage)CSETWeb_Api.Helpers.ElmahWrapper.LogAndReportException(e, Request, HttpContext.Current);
            }
        }
        public void SetupOrganisationTests()
        {
            _databaseConnection = new SqlConnection(_databaseService.WebConfiguration.SqlConnectionString);
            _unitOfWork         = new UnitOfWork(_databaseConnection);
            _repository         = new StandardRepository(_unitOfWork);
            _standardId1        = 1;
            _standardId2        = 10;
            _standardId3        = 100;
            _referenceNumber1   = "ST0001";
            _referenceNumber2   = "ST0010";
            _title1             = "Standard 1";
            _title2             = "Standard title 2";
            _title3             = "standard title 3";
            _standardDataLevel1 = 4;
            _standardData1      = "{\"Level\": " + _standardDataLevel1 + " }";

            _standardCollation1 = new StandardCollationModel
            {
                StandardId      = _standardId1,
                ReferenceNumber = _referenceNumber1,
                Title           = _title1,
                StandardData    = _standardData1
            };

            _standardCollation2 = new StandardCollationModel
            {
                StandardId      = _standardId2,
                ReferenceNumber = _referenceNumber2,
                Title           = _title2,
                StandardData    = null
            };

            _standardCollation3 = new StandardCollationModel
            {
                StandardId      = _standardId3,
                ReferenceNumber = null,
                Title           = _title3,
                StandardData    = null
            };

            StandardCollationHandler.InsertRecords(new List <StandardCollationModel> {
                _standardCollation1, _standardCollation2, _standardCollation3
            });
        }
Example #7
0
        //IGenericRepository IUnitOfWork.Repository => throw new NotImplementedException();

        public UnitOfWork()
        {
            dbContext                  = new DatabaseContext();
            Repository                 = new GenericRepository(dbContext);
            SchoolRepository           = new SchoolRepository(dbContext);
            ExceptionLoggerRepository  = new ExceptionLoggerRepository(dbContext);
            ApiLogRepository           = new ApiLogRepository(dbContext);
            ImageFileTypeRepository    = new ImageFileTypeRepository(dbContext);
            AssessmentRepository       = new AssessmentRepository(dbContext);
            AttendanceRepository       = new AttendanceRepository(dbContext);
            BookRepository             = new BookRepository(dbContext);
            BookTransactionRepository  = new BookTransactionRepository(dbContext);
            EventRepository            = new EventRepository(dbContext);
            HomeworkRepository         = new HomeworkRepository(dbContext);
            ImageFileUrlRepository     = new ImageFileUrlRepository(dbContext);
            ParentRepository           = new ParentRepository(dbContext);
            StandardRepository         = new StandardRepository(dbContext);
            StudentRepository          = new StudentRepository(dbContext);
            SubjectRepository          = new SubjectRepository(dbContext);
            TeacherRepository          = new TeacherRepository(dbContext);
            YearRepository             = new YearRepository(dbContext);
            OperationalStaffRepository = new OperationalStaffRepository(dbContext);
        }
Example #8
0
        public IHttpActionResult PostSAL(Sals tmpsal)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            int assessmentId = Auth.AssessmentForUser();

            TinyMapper.Bind <Sals, STANDARD_SELECTION>();
            STANDARD_SELECTION sTANDARD_SELECTION = db.STANDARD_SELECTION.Where(x => x.Assessment_Id == assessmentId).FirstOrDefault();

            if (sTANDARD_SELECTION != null)
            {
                sTANDARD_SELECTION = TinyMapper.Map <Sals, STANDARD_SELECTION>(tmpsal, sTANDARD_SELECTION);
            }
            else
            {
                sTANDARD_SELECTION = TinyMapper.Map <STANDARD_SELECTION>(tmpsal);
            }
            sTANDARD_SELECTION.Assessment_Id = assessmentId;


            db.Entry(sTANDARD_SELECTION).State = EntityState.Modified;
            LevelManager lm = new LevelManager(assessmentId, db);

            lm.SaveOtherLevels(assessmentId, tmpsal);
            lm.Init(sTANDARD_SELECTION);
            if (tmpsal.SelectedSALOverride)
            {
                lm.SaveSALLevel(tmpsal.Selected_Sal_Level);
            }

            try
            {
                db.SaveChanges();

                StandardRepository sr = new StandardRepository(assessmentId, lm, new StandardManager(), new AssessmentModeData(db, assessmentId), new StandardSpecficLevelRepository(db));
                sr.Confidence_Level   = tmpsal.CLevel;
                sr.Integrity_Level    = tmpsal.ILevel;
                sr.Availability_Level = tmpsal.ALevel;

                // save the newly-calculated overall value
                if (!tmpsal.SelectedSALOverride)
                {
                    tmpsal.Selected_Sal_Level = sr.Selected_Sal_Level;
                    lm.SaveSALLevel(tmpsal.Selected_Sal_Level);
                }

                return(Ok(tmpsal));
            }
            catch (DbUpdateConcurrencyException dbe)
            {
                if (!STANDARD_SELECTIONExists(assessmentId))
                {
                    return(NotFound());
                }
                else
                {
                    throw dbe;
                }
            }
            catch (Exception e)
            {
                CSETWeb_Api.Helpers.ElmahWrapper.LogAndReportException(e, Request, HttpContext.Current);
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #9
0
        public void SetupStandardCollationTests()
        {
            _databaseConnection = new SqlConnection(_databaseService.WebConfiguration.SqlConnectionString);
            _unitOfWork         = new UnitOfWork(_databaseConnection);
            _repository         = new StandardRepository(_unitOfWork);

            _standardCollations.Add(new StandardCollationModel
            {
                StandardId      = _firstStandardId,
                ReferenceNumber = _firstStandardReference,
                Title           = $"Standard title {_firstStandardId}",
                StandardData    = JsonConvert.SerializeObject(new StandardDataModel
                {
                    Level = 1
                }),
                Options = new List <OptionDataModel>
                {
                    new OptionDataModel
                    {
                        StdCode    = _firstStandardId,
                        OptionName = $"Option {_firstStandardId}.1",
                        IsLive     = 1
                    },
                    new OptionDataModel
                    {
                        StdCode    = 1,
                        OptionName = $"Option {_firstStandardId}.2",
                        IsLive     = 1
                    },
                    new OptionDataModel
                    {
                        StdCode    = 1,
                        OptionName = $"Option {_firstStandardId}.3",
                        IsLive     = 0
                    }
                },
                IsLive = 1
            });

            _standardCollations.Add(new StandardCollationModel
            {
                StandardId      = _secondStandardId,
                ReferenceNumber = _secondStandardReference,
                Title           = $"Standard title {_secondStandardId}",
                StandardData    = JsonConvert.SerializeObject(new StandardDataModel
                {
                    Level = 2
                }),
                Options = new List <OptionDataModel>
                {
                    new OptionDataModel
                    {
                        StdCode    = _secondStandardId,
                        OptionName = $"Option {_secondStandardId}.1",
                        IsLive     = 1
                    },
                    new OptionDataModel
                    {
                        StdCode    = _secondStandardId,
                        OptionName = $"Option {_secondStandardId}.2",
                        IsLive     = 1
                    }
                },
                IsLive = 1
            });

            _standardCollations.Add(new StandardCollationModel
            {
                StandardId      = _thirdStandardId,
                ReferenceNumber = _thirdStandardReference,
                Title           = $"Standard title {_thirdStandardId}",
                StandardData    = null,
                Options         = new List <OptionDataModel>(),
                IsLive          = 1
            });

            _standardCollations.Add(new StandardCollationModel
            {
                StandardId      = _fourthStandardId,
                ReferenceNumber = _fourthStandardReference,
                Title           = $"Standard title {_fourthStandardId}",
                StandardData    = JsonConvert.SerializeObject(new StandardDataModel
                {
                    Level = 4
                }),
                Options = new List <OptionDataModel>
                {
                    new OptionDataModel
                    {
                        StdCode    = _fourthStandardId,
                        OptionName = $"Option {_fourthStandardId}.1",
                        IsLive     = 0
                    },
                    new OptionDataModel
                    {
                        StdCode    = _fourthStandardId,
                        OptionName = $"Option {_fourthStandardId}.2",
                        IsLive     = 1
                    }
                },
                IsLive = 0
            });

            StandardCollationHandler.InsertRecords(_standardCollations);
        }