public IActionResult Create(Classroom model) { string Id = null; if (_signInManager.IsSignedIn(HttpContext.User)) { Id = _userManager.GetUserId(HttpContext.User); } if (ModelState.IsValid) { Classroom newClass = new Classroom { title = model.title, description = model.description, AppUserID = Id, time_created = DateTime.Now }; _classRepo.Add(newClass); ClassroomUser newClassUser = new ClassroomUser { ClassroomId = newClass.ID, AppUserId = Id, Role = "Mentor" }; _classUserRepo.Add(newClassUser); return(RedirectToAction("Home", new { id = newClass.ID, loadPartial = "BlackBoard" })); } return(View()); }
public IActionResult Home(int id, string loadPartial) { Classroom Classroom = _classRepo.GetClassroom(id); string userId = null; if (_signInManager.IsSignedIn(HttpContext.User)) { userId = _userManager.GetUserId(HttpContext.User); } ClassroomUser classUser = _classUserRepo.GetClassroomUser(id, userId); if (Classroom == null || classUser == null) { Response.StatusCode = 404; return(View("NotFound")); } ClassroomHomeViewModel chvm = new ClassroomHomeViewModel(); chvm.Classroom = Classroom; chvm.BlackBoards = _boardRepo.GetClassBlackBoards(id); List <List <Comment> > Comments = new List <List <Comment> >(); foreach (BlackBoard bb in chvm.BlackBoards) { Comments.Add(_commentRepo.GetBlackBoardComments(bb.Id).ToList()); } chvm.Comments = Comments; chvm.ClassroomUserRole = classUser.Role; chvm.ClassroomMentors = _classUserRepo.GetClassroomMentors(id); chvm.ClassroomStudents = _classUserRepo.GetClassroomStudents(id); chvm.StudentInvites = _inviteRepo.GetAllInvites(id); chvm.Assignments = _assignmentRepo.GetClassAssignments(id); ViewData["loadPartial"] = loadPartial; return(View(chvm)); }
ClassroomUser IClassroomUserRepository.Delete(int classId, string userId) { ClassroomUser ClassroomUser = context.ClassroomUsers.Find(classId, userId); if (ClassroomUser != null) { context.ClassroomUsers.Remove(ClassroomUser); context.SaveChanges(); } return(ClassroomUser); }
public IActionResult AcceptStudentInvite(int id) { int classid = id; string userId = _userManager.GetUserId(HttpContext.User); string useremail = _userManager.FindByIdAsync(userId).Result.Email; ClassroomUser newClassUser = new ClassroomUser { ClassroomId = classid, AppUserId = userId, Role = "Student" }; _classUserRepo.Add(newClassUser); _inviteRepo.Delete(classid, useremail); return(RedirectToAction("Home", new { id = classid, loadPartial = "BlackBoard" })); }
public IActionResult ViewSubmissions(int id) { string userId = null; if (_signInManager.IsSignedIn(HttpContext.User)) { userId = _userManager.GetUserId(HttpContext.User); } Assignment assignment = _assignmentRepo.GetAssignment(id); if (assignment == null) { return(View("NotFound")); } ClassroomUser classroomUser = _classUserRepo.GetClassroomUser(assignment.ClassroomID, userId); if (classroomUser == null) { return(View("NotFound")); } ViewData["AssignmentTitle"] = assignment.Title; ViewData["Role"] = classroomUser.Role; ViewBag.ClassId = assignment.ClassroomID; IEnumerable <SubmittedAssignment> assignments = null; if (classroomUser.Role == "Mentor") { ViewData["EmptyMessage"] = "No submissions right now T-T. Check again later."; IEnumerable <ClassroomUser> notSubmitted = _submittedAssignmentRepo.GetPeopleNotSubmitted(id); ViewData["Count"] = notSubmitted.Count(); ViewBag.RemainingPeople = notSubmitted; assignments = _submittedAssignmentRepo.GetSubmittedAssignments(id); } if (classroomUser.Role == "Student") { ViewData["EmptyMessage"] = "You haven't made any submissions yet -.- !"; assignments = _submittedAssignmentRepo.GetUserSubmittedAssignments(id, userId); } return(View(assignments)); }
ClassroomUser IClassroomUserRepository.Add(ClassroomUser classroomUser) { context.ClassroomUsers.Add(classroomUser); context.SaveChanges(); return(classroomUser); }