public List <TestSetupVM> GetAllTestDetails()
        {
            Query = "SELECT TestSetup.TestName,TestSetup.Fee,TestType.TypeName FROM TestType INNER JOIN TestSetup ON TestType.TypeId=TestSetup.TypeId ORDER BY TestName";


            Command = new SqlCommand(Query, Connection);
            Connection.Open();

            List <TestSetupVM> tests = new List <TestSetupVM>();

            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                TestSetupVM test = new TestSetupVM();
                test.TestName = Reader["TestName"].ToString();
                test.Fee      = (double)Reader["Fee"];
                test.TypeName = Reader["TypeName"].ToString();

                tests.Add(test);
            }
            Reader.Close();
            Connection.Close();

            return(tests);
        }
Example #2
0
        public bool AddTestSetup(TestSetupVM model)
        {
            if (model == null)
            {
                throw new Exception("There is no Entry!");
            }

            var setUp = new TestSetup()
            {
                DisplayResult = model.DisplayResult,
                EndDate       = model.EndDate,
                StartDate     = model.StartDate,
                StartTime     = model.StartTime,
                StopTime      = model.StopTime
            };

            _context.TestSetup.Add(setUp);

            if (_context.SaveChanges() > 0)
            {
                var testSetupId = setUp.TestSetupId;

                foreach (var id in model.QuestionBankIds)
                {
                    var publishQuestion = new PublishedQuestion
                    {
                        QuestionBankId = id.questionBankId,
                        TestSetupId    = testSetupId
                    };

                    _context.PublishedQuestion.Add(publishQuestion);
                }
            }
            return(_context.SaveChanges() > 0);
        }
        public List <TestSetupVM> GetAllTestSetupwithType()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        quary      = "Select * from TestVM";
            SqlCommand    command    = new SqlCommand(quary, connection);

            connection.Open();

            SqlDataReader reader = command.ExecuteReader();

            List <TestSetupVM> testSetups = new List <TestSetupVM>();

            while (reader.Read())
            {
                TestSetupVM testSetup = new TestSetupVM();
                //testSetup.Id = Convert.ToInt32(reader["Id"].ToString());
                testSetup.TestName     = reader["TestName"].ToString();
                testSetup.Fee          = Convert.ToDouble(reader["Fee"].ToString());
                testSetup.TestTypeName = reader["TestType"].ToString();
                testSetups.Add(testSetup);
            }
            reader.Close();
            connection.Close();
            return(testSetups);
        }
Example #4
0
        public bool UpdateTestSetup(TestSetupVM model)
        {
            var setupData = _context.TestSetup.Find(model.TestSetupId);

            if (setupData == null)
            {
                throw new Exception("Record not found");
            }

            setupData.DisplayResult = model.DisplayResult;
            setupData.EndDate       = model.EndDate;
            setupData.StartDate     = model.StartDate;
            setupData.StartTime     = model.StartTime;
            setupData.EndDate       = model.EndDate;


            return(_context.SaveChanges() > 0);
        }