public CandidateTestModel AddTestSubmission(int candidateId, AddTestSubmissionRequestModel testSubmissionModel)
        {
            var result = _context.CandidateTests
                         .SingleOrDefault(s => s.CandidateId == candidateId && s.TestId == testSubmissionModel.TestId);

            if (result != null)
            {
                result.TestAnswer = testSubmissionModel.TestAnswer;
                result.EndTime    = DateTime.Now;
                _context.SaveChanges();
                return(result);
            }
            else
            {
                var insertTest = _context.CandidateTests.Add(new CandidateTestModel()
                {
                    CandidateId = candidateId,
                    TestId      = testSubmissionModel.TestId,
                    TestAnswer  = testSubmissionModel.TestAnswer,
                    EndTime     = DateTime.Now,
                });
                _context.SaveChanges();
                return(insertTest.Entity);
            }
        }
        public void CreateNewAdminUser(string email, string password)
        {
            var salt         = _passwordService.GenerateSalt();
            var newAdminUser = new AdminUserDataModel()
            {
                Email          = email,
                PasswordSalt   = salt,
                HashedPassword = _passwordService.HashPassword(password, salt),
            };

            _context.AdminUsers.Add(newAdminUser);
            _context.SaveChanges();
        }
        public CandidateDataModel Register(CandidateRequest candidateRequest)
        {
            var response = _context.Candidates.Add(new CandidateDataModel()
            {
                FirstName      = candidateRequest.FirstName,
                LastName       = candidateRequest.LastName,
                Email          = candidateRequest.Email,
                Guid           = Guid.NewGuid().ToString(),
                CandidateTests = new List <CandidateTestModel>
                {
                    new CandidateTestModel
                    {
                        TestId = 1,
                    },
                    new CandidateTestModel
                    {
                        TestId = 2,
                    },
                    new CandidateTestModel
                    {
                        TestId = 3,
                    },
                },
            });

            _context.SaveChanges();
            return(response.Entity);
        }