public void SaveCheckTime(tblCheckIN tblCheckINs) { var quote = (from h in db.tblCourseHDs join d in db.tblCourseDTs on h.CourseHDID equals d.CourseHDID where h.CourseHDID == tblCheckINs.CourseHDID && d.StudID == tblCheckINs.StudID select h).ToList(); if (quote.Count > 0) { tblCheckINs.CheckInID = Guid.NewGuid().ToString(); tblCheckINs.TimeCheck = DateTime.Now; db.tblCheckINs.Add(tblCheckINs); db.SaveChanges(); } }
public JsonResult SaveCheckTime(tblCheckIN tblCheckINsTemp) { var chkStud = db.tblStudents.Where(s => s.StudID == tblCheckINsTemp.StudID || s.StudCode == tblCheckINsTemp.StudID).ToList(); if (chkStud.Count > 0) { tblCheckINsTemp.StudID = chkStud[0].StudID; var quote = (from h in db.tblCourseHDs join d in db.tblCourseDTs on h.CourseHDID equals d.CourseHDID join s in db.tblStudents on d.StudID equals s.StudID where h.CourseHDID == tblCheckINsTemp.CourseHDID && d.StudID == tblCheckINsTemp.StudID select h).ToList(); if (quote.Count > 0) { var chk = (from c in db.tblCheckINs where c.CourseHDID == tblCheckINsTemp.CourseHDID && c.StudID == tblCheckINsTemp.StudID && c.NumCheck == tblCheckINsTemp.NumCheck select c).ToList(); if (chk.Count > 0) { return(Json(new { Success = 3 })); } else { tblCheckINsTemp.CheckInID = Guid.NewGuid().ToString(); tblCheckINsTemp.TimeCheck = DateTime.Now; db.tblCheckINs.Add(tblCheckINsTemp); db.SaveChanges(); return(Json(new { Success = 1 })); } } else { return(Json(new { Success = 2 })); } } else { return(Json(new { Success = 2 })); } }