public bool TryGet(int id, out testpaper tp) { tp = db.testpaper.Where(p => p.ID == id).FirstOrDefault(); if (tp != null) { return(true); } else { return(false); } }
public bool UpdateByID(int id, testpaper tp) { var result = db.testpaper.Where(p => p.ID == id).FirstOrDefault(); if (result != null) { // 测试名字属性 result.TestPaperName = tp.TestPaperName; db.SaveChanges(); return(true); } else { return(false); } }
public testpaper Add(testpaper tp) { // 取机构用户id int organizationUserID = (int)tp.ID; // 向试卷表中添加 tp = db.testpaper.Add(tp); // 向生成关系表中添加 generate_testpaper_between_organizationuser_and_testpaper tmp = new generate_testpaper_between_organizationuser_and_testpaper { OrganizationUserID = organizationUserID, TestPaperID = (int)tp.ID, TimeOfGeneration = DateTime.Now }; db.generate_testpaper_between_organizationuser_and_testpaper.Add(tmp); db.SaveChanges(); return(tp); }
public bool UpdateByID(int id, testpaper tp) { var result = db.testpaper.Where(p => p.ID == id).FirstOrDefault(); if (result != null) { result.Amount1 = tp.Amount1; result.Amount2 = tp.Amount2; result.Amount3 = tp.Amount3; result.Amount4 = tp.Amount4; result.Amount5 = tp.Amount5; result.Amount6 = tp.Amount6; result.TestPaperName = tp.TestPaperName; db.SaveChanges(); return(true); } else { return(false); } }
public testpaper Add(testpaper tp) { tp = db.testpaper.Add(tp); db.SaveChanges(); return(tp); }