コード例 #1
0
ファイル: GroupController.cs プロジェクト: bbffbb/my-toolbox
        public ActionResult LeaveGroup(int Id)
        {
            var userService      = new UserService(myDbContext);
            var groupListService = new GroupListService(myDbContext);
            var userId           = User.Identity.GetUserId();
            var user             = userService.GetUser(userId);
            var groupList        = groupListService.getGroupList(Id, user);

            groupListService.LeaveGroup(groupList);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
ファイル: GroupController.cs プロジェクト: bbffbb/my-toolbox
        public ActionResult JoinGroup(int Id)
        {
            var userService      = new UserService(myDbContext);
            var groupListService = new GroupListService(myDbContext);
            var userId           = User.Identity.GetUserId();
            var user             = userService.GetUser(userId);

            if (groupListService.getGroupList(Id, user) != null)
            {
                return(RedirectToAction("Index"));
            }

            var groupList    = new GroupList();
            var groupService = new GroupService(myDbContext);

            groupList.Group = groupService.GetGroup(Id);
            groupList.User  = user;
            groupListService.AddGroupToList(groupList);

            return(RedirectToAction("Index"));
        }