Beispiel #1
0
 public ActionResult AddTestTaker(JsonAudienceTestTaker testTaker)
 {
     try
     {
         var audience = db.Audiences.FirstOrDefault(a => a.AudienceId == testTaker.audienceId);
         if (audience == null)
         {
             throw new Exception("Aiduence not found");
         }
         var testTakerToAdd   = new TestTaker(audience, testTaker.email);
         var contactInfoToAdd = new ContactInfo(testTaker.contactInfo);
         testTakerToAdd.ContactInfo = contactInfoToAdd;
         db.ContactInfos.Add(contactInfoToAdd);
         db.TestTakers.Add(testTakerToAdd);
         db.SaveChanges();
         return(Json(new
         {
             success = true,
             id = testTakerToAdd.TestTakerId
         }));
     } catch (Exception exc)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
 }
Beispiel #2
0
        public async Task <IActionResult> Proceed()
        {
            TestTaker testTaker = new TestTaker();

            testTaker = await _intellectDbContext.TestTakers.LastOrDefaultAsync();

            return(View(testTaker));
        }
Beispiel #3
0
        public async Task <IActionResult> Enroll(TestTaker testTaker, DateTime birthdate)
        {
            if (ModelState.IsValid)
            {
                testTaker.Birth         = birthdate;
                testTaker.Result        = 0;
                testTaker.UserQuestions = await _intellectDbContext.Questions.Where(q => q.ExamId == 3).Select(q => new UserQuestion {
                    Question = q, TestTaker = testTaker
                }).ToListAsync();

                _intellectDbContext.TestTakers.Add(testTaker);
                await _intellectDbContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Proceed)));
            }
            else
            {
                ModelState.AddModelError("", "Kecmedi");
                return(View());
            }
        }
Beispiel #4
0
        public int AddTestTaker(TestTaker testTaker)
        {
            string procName    = "spTestTakerInsert";
            var    param       = new DynamicParameters();
            int    TestTakerID = 0;

            param.Add("@TestTakerID", testTaker.TestTakerID, null, ParameterDirection.Output);

            try
            {
                SqlMapper.Execute(_connectionFactory.GetConnection,
                                  procName, param, commandType: CommandType.StoredProcedure);

                TestTakerID = param.Get <int>("@TestTakerID");
            }
            finally
            {
                _connectionFactory.CloseConnection();
            }

            return(TestTakerID);
        }
Beispiel #5
0
        public bool UpdateTestTaker(int TestTakerID, TestTaker testTaker)
        {
            string procName  = "spTestTakerUpdate";
            var    param     = new DynamicParameters();
            bool   IsSuccess = true;

            param.Add("@TestTakerID", TestTakerID, null, ParameterDirection.Input);

            try
            {
                var rowsAffected = SqlMapper.Execute(_connectionFactory.GetConnection,
                                                     procName, param, commandType: CommandType.StoredProcedure);
                if (rowsAffected <= 0)
                {
                    IsSuccess = false;
                }
            }
            finally
            {
                _connectionFactory.CloseConnection();
            }

            return(IsSuccess);
        }
Beispiel #6
0
        public TestTaker GetTestTakerByID(int testTakerID)
        {
            var TestTaker = new TestTaker();
            var procName  = "spTestTakerFetch";
            var param     = new DynamicParameters();

            param.Add("@TestTakerID", testTakerID);

            try
            {
                using (var multiResult = SqlMapper.QueryMultiple(_connectionFactory.GetConnection,
                                                                 procName, param, commandType: CommandType.StoredProcedure))
                {
                    TestTaker = multiResult.ReadFirstOrDefault <TestTaker>();
                    //TestTaker.Territories = multiResult.Read<TestTakerTerritory>().ToList();
                }
            }
            finally
            {
                _connectionFactory.CloseConnection();
            }

            return(TestTaker);
        }