public ActionResult View(string id) { if (string.IsNullOrEmpty(id)) { using (var context = new AttendanceTrackerDatabaseConnection()) { var aspUserId = User.Identity.GetUserId(); id = context.Users.FirstOrDefault(x => x.AspNetUsersId == aspUserId).Id.ToString(); } } return(View(UserViewModel.ViewUser(id, UserRolesModel.IsAdmin(User.Identity.GetUserId())))); }
public ActionResult Edit(string id) { var userId = User.Identity.GetUserId(); if (UserRolesModel.IsTeacher(userId) || UserRolesModel.IsAdmin(userId)) { return(View(CourseEditModel.CourseEdit(id))); } else { return(RedirectToAction("Unauthorized", "User")); } }
// GET: User public ActionResult Index() { var userId = User.Identity.GetUserId(); if (UserRolesModel.IsAdmin(userId)) { return(View()); } else { return(RedirectToAction("Unauthorized", "User")); } }
public ActionResult AddStudentPost(CourseStudentEditModel model) { var userId = User.Identity.GetUserId(); if (UserRolesModel.IsTeacher(userId) || UserRolesModel.IsAdmin(userId)) { JsonResult json = new JsonResult(); json.Data = CourseStudentEditModel.CourseStudentEditPost(model).CourseId; return(json); } else { return(RedirectToAction("Unauthorized", "User")); } }
public ActionResult EditPost(CourseEditModel courseModel) { var userId = User.Identity.GetUserId(); if (UserRolesModel.IsTeacher(userId) || UserRolesModel.IsAdmin(userId)) { JsonResult jsonResult = new JsonResult(); jsonResult.Data = CourseEditModel.CourseEditPost(courseModel, User.Identity.GetUserId()).Id; return(jsonResult); } else { return(RedirectToAction("Unauthorized", "User")); } }
public ActionResult RemoveStudentPost(string id) { var userId = User.Identity.GetUserId(); if (UserRolesModel.IsTeacher(userId) || UserRolesModel.IsAdmin(userId)) { JsonResult json = new JsonResult(); var run = CourseStudentEditModel.CourseStudentRemovePost(id); json.Data = "ok"; json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(json); } else { return(RedirectToAction("Unauthorized", "User")); } }
public ActionResult View(string id) { var userId = User.Identity.GetUserId(); return(View(CourseViewModel.ViewCourse(id, UserRolesModel.IsAdmin(userId), UserRolesModel.IsTeacher(userId), UserRolesModel.IsStudent(userId)))); }
// // GET: /Manage/Index public async Task <ActionResult> Index(ManageMessageId?message) { ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set." : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." : message == ManageMessageId.Error ? "An error has occurred." : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." : ""; var userId = User.Identity.GetUserId(); var model = new IndexViewModel { HasPassword = HasPassword(), PhoneNumber = await UserManager.GetPhoneNumberAsync(userId), TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId), Logins = await UserManager.GetLoginsAsync(userId), BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId), IsStudent = UserRolesModel.IsStudent(User.Identity.GetUserId()) || (!UserRolesModel.IsTeacher(User.Identity.GetUserId()) && !UserRolesModel.IsAdmin(User.Identity.GetUserId())) }; return(View(model)); }
public ActionResult Edit(string id) { var userId = User.Identity.GetUserId(); return(View(UserEditModel.UserEdit(id, UserRolesModel.IsAdmin(userId)))); }