예제 #1
0
        public BankSoal GetNewSoal(int sesiId)
        {
            BankSoal obj = null;

            try
            {
                var random = new Random();

                var sql    = @"select bank_soal_id from bank_soal 
                            where bank_soal_id not in (select bank_soal_id from histori_tes where sesi_id = @sesiId)";
                var soalId = _context.Db.Query <int>(sql, new { sesiId })
                             .OrderBy(f => random.Next()).Take(1)
                             .FirstOrDefault();

                obj = GetById(soalId);

                if (obj != null)
                {
                    IHistoriTesRepository repo = new HistoriTesRepository(_context);
                    obj.nomor_soal = repo.GetSoalNumber(sesiId);
                }
            }
            catch (Exception ex)
            {
                //_log.Error("Error:", ex);
            }

            return(obj);
        }
예제 #2
0
        public BankSoal GetNewSoal(int sesiId)
        {
            BankSoal obj = null;

            using (IDbContext context = new DbContext())
            {
                _repository = new BankSoalRepository(context);
                obj         = _repository.GetNewSoal(sesiId);
            }

            return(obj);
        }
예제 #3
0
        public BankSoal GetById(int soalId)
        {
            BankSoal obj = null;

            using (IDbContext context = new DbContext())
            {
                _repository = new BankSoalRepository(context);
                obj         = _repository.GetById(soalId);
            }

            return(obj);
        }
예제 #4
0
        public BankSoal GetById(int soalId)
        {
            BankSoal obj = null;

            try
            {
                obj = _context.Db.Get <BankSoal>(soalId);
            }
            catch (Exception ex)
            {
                //_log.Error("Error:", ex);
            }

            return(obj);
        }