public IHttpActionResult PutScore(DataLayerTest.Test test)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            //using (var ctx = new Test())
            //{
            var existingScore = db.Test.Where(s => s.TestID == test.TestID && s.QuesCategoryID == test.QuesCategoryID).FirstOrDefault <Test>();

            if (existingScore.Score == null)
            {
                existingScore.Score = test.Score;
                //existingStudent.LastName = student.LastName;

                db.SaveChanges();
            }
            else
            {
                return(NotFound());
            }
            //}

            return(Ok());
        }
        public int insertEmployee(tblEmployee emp)
        {
            DataLayerTest.Test test = new DataLayerTest.Test();
            tblEmployee        emp1 = new tblEmployee();

            emp1.EmployeeID = emp.EmployeeID;
            bool exists = (from employee in db.tblEmployee
                           where employee.EmployeeID == emp1.EmployeeID
                           select employee).Any();

            if (exists)
            {
                return(0);
            }

            else
            {
                db.tblEmployee.Select(e => e.EmployeeID == emp1.EmployeeID);
                db.tblEmployee.Add(emp1);
                db.SaveChanges();
                int?TestID = db.Test.Max(u => (int?)u.TestID);
                if (TestID != null)
                {
                    test.TestID = Convert.ToInt16(TestID + 1);
                }
                else
                {
                    test.TestID = 1;
                }

                test.Emp_Cand_ID    = Convert.ToString(emp1.EmployeeID);
                test.QuesCategoryID = 1;//1 hardcorded for Logical Section bcz by default first question will be Logical.
                db.Test.Add(test);
                db.SaveChanges();

                return(test.TestID);
            }
        }
예제 #3
0
        public int insertCandidates(tblCandidate cand)
        {
            tblCandidate cand1 = new tblCandidate();

            DataLayerTest.Test test = new DataLayerTest.Test();
            cand1.FirstName   = cand.FirstName;
            cand1.LastName    = cand.LastName;
            cand1.DOB         = cand.DOB;
            cand1.EmailID     = cand.EmailID;
            cand1.Experience  = cand.Experience;
            cand1.Designation = cand.Designation;


            db.tblCandidate.Add(cand1);
            db.SaveChanges();

            int?TestID = db.Test.Max(u => (int?)u.TestID);

            if (TestID != null)
            {
                test.TestID = Convert.ToInt16(TestID + 1);
            }
            else
            {
                test.TestID = 1;
            }

            test.Emp_Cand_ID    = Convert.ToString(cand1.CandidateID);
            test.QuesCategoryID = 1;//1 hardcorded for Logical Section bcz by default first question will be Logical.
            db.Test.Add(test);
            db.SaveChanges();

            int TestID1 = test.TestID;

            //insert into tblCandidate Table
            return(TestID1);
        }