public List<testsinfo> getspecifictestinfo(int k) { var Emplist = new List<testsinfo>(); onlinetestingEntities4 gettest = new onlinetestingEntities4(); foreach (var i in gettest.testDatas.ToList()) { if (i.user_id == k) { testsinfo t1 = new testsinfo(); t1.test_ID = i.test_id; t1.user_ID = i.user_id; t1.test_name = i.testName; t1.test_Sub = i.testSubject; t1.test_max = i.testMaxMarks; t1.test_time = i.testTime; t1.test_details = i.testDetails; Emplist.Add(t1); } } return Emplist; }
public bool inserttestDetails(testsinfo testInsert) { onlinetestingEntities4 tests = new onlinetestingEntities4(); testData newtest = new testData(); newtest.test_id = testInsert.test_ID; newtest.user_id = testInsert.user_ID; newtest.testName = testInsert.test_name; newtest.testSubject = testInsert.test_Sub; newtest.testTime = testInsert.test_time; newtest.testMaxMarks = testInsert.test_max; newtest.testDetails = testInsert.test_details; tests.testDatas.Add(newtest); tests.SaveChanges(); return true; }