public JsonResult Add() { if (!Permission.LoginedNeed(Request, Response, Session)) { return(Json(false)); } User user = (User)Session["user"]; int gid = Convert.ToInt32(Request["gid"]); string username = Request["username"]; GroupMember memberInfo = GroupView.GetGroupMember(user.uid, gid); if (memberInfo == null || memberInfo.rank < (int)MemberRank.ADMINISTRATOR) { return(Json(false)); } User newMember = UserView.GetUserByUsername(username); if (newMember == null) { return(Json(false)); } GroupMember newMemberInfo = new GroupMember { uid = newMember.uid, gid = gid, rank = 0 }; return(Json(GroupView.AddMember(gid, newMemberInfo))); }
public JsonResult SubmitChange() { if (!Permission.LoginedNeed(Request, Response, Session)) { return(Json(false)); } User user = (User)Session["user"]; int gid = Convert.ToInt32(Request["gid"]); int uid = Convert.ToInt32(Request["uid"]); int rank = Convert.ToInt32(Request["rank"]); GroupMember opInfo = GroupView.GetGroupMember(user.uid, gid); GroupMember memberInfo = GroupView.GetGroupMember(uid, gid); if (opInfo == null || memberInfo == null || rank >= 3 || rank < 0 || opInfo.rank < (int)MemberRank.ADMINISTRATOR || memberInfo.rank == (int)MemberRank.CREATOR) { return(Json(false)); } memberInfo.rank = rank; return(Json(GroupView.SaveGroupMember(memberInfo))); }
public JsonResult Join() { if (!Permission.LoginedNeed(Request, Response, Session)) { return(Json(false)); } User user = (User)Session["user"]; int gid = Convert.ToInt32(Request["gid"]); Group group = GroupView.GetGroupById(gid); if (group == null || group.allow_join == false) { Json(false); } if (GroupView.GetGroupMember(user.uid, gid) != null) { return(Json(false)); } GroupMember member = new GroupMember { uid = user.uid, gid = gid, rank = (int)MemberRank.MEMBER }; return(Json(GroupView.AddMember(gid, member))); }
public JsonResult Quit() { if (!Permission.LoginedNeed(Request, Response, Session)) { return(Json(false)); } User user = (User)Session["user"]; int gid = Convert.ToInt32(Request["gid"]); GroupMember memberInfo = GroupView.GetGroupMember(user.uid, gid); if (memberInfo == null || memberInfo.rank == (int)MemberRank.CREATOR) { return(Json(false)); } return(Json(GroupView.QuitGroup(memberInfo))); }
public ActionResult AddMember(int id = 0) { if (!Permission.LoginedNeed(Request, Response, Session)) { return(null); } User user = (User)Session["user"]; GroupMember memberInfo = GroupView.GetGroupMember(user.uid, id); if (memberInfo == null || memberInfo.rank < (int)MemberRank.ADMINISTRATOR) { Permission.BackToPrevPageOrIndex(Request, Response); return(null); } ViewBag.memberInfo = memberInfo; return(View()); }
public ActionResult Members(int id = 0) { if (!Permission.LoginedNeed(Request, Response, Session)) { return(null); } User user = (User)Session["user"]; GroupMember memberInfo = GroupView.GetGroupMember(user.uid, id); if (memberInfo == null) { Permission.BackToPrevPageOrIndex(Request, Response); return(null); } ViewBag.memberInfo = memberInfo; ViewBag.members = GroupView.GetGroupMemberByGID(id).ToList(); return(View()); }
public ActionResult Exams(int id = 0) { if (!Permission.LoginedNeed(Request, Response, Session)) { return(null); } User user = (User)Session["user"]; GroupMember memberInfo = GroupView.GetGroupMember(user.uid, id); if (memberInfo == null) { Permission.BackToPrevPageOrIndex(Request, Response); return(null); } Pager <Exam> pager = new Pager <Exam>(); ViewBag.memberInfo = memberInfo; ViewBag.exams = ExamView.GetAllExamByGroup(id).Where(e => e.end_date < DateTime.Now).ToList(); return(View()); }