public ActionResult Index_Home() { //Neu bam vao mon dang day, moi ra index //Tim instructor da dang nhạp vao string Username = this.HttpContext.User.Identity.Name; User User = AccBO.GetUserByUsername(Username); Instructor AuthorizedInstructor = InsBO.GetInstructorByUserID(User.UserID); //Nhung mon ma instructor nay dang day, sau nay phai check status var RollCalls = RollBO.GetInstructorCurrentRollCalls(AuthorizedInstructor.InstructorID); //Mon dang day vao thoi diem dang nhap RollCall CurrentRollCall = null; TimeSpan CurrentTime = DateTime.Now.TimeOfDay; if (RollCalls.Count() > 0) { CurrentRollCall = RollCalls.FirstOrDefault(r => r.StartTime <= CurrentTime && r.EndTime >= CurrentTime); } InstructorViewModel model = new InstructorViewModel(); model.AuthorizedInstructor = AuthorizedInstructor; model.CurrentRollCall = CurrentRollCall; model.TeachingRollCall = RollCalls; return(View(model)); }
public ActionResult Login(string Username, string Password) { AccountBusiness AccBO = new AccountBusiness(); InstructorBusiness InsBO = new InstructorBusiness(); User user = AccBO.CheckLogin(Username, Password); if (user == null) { return(Json(new { message = "Invalid" })); } else { Instructor AuthorizedInstructor = InsBO.GetInstructorByUserID(user.UserID); return(Json(new { message = "Success", instructorName = AuthorizedInstructor.Fullname, instructorID = AuthorizedInstructor.InstructorID })); } }