コード例 #1
0
        public ActionResult DeleteTeam(int teamId, string id, FormCollection collection)
        {
            SystemUserTeamRepository systemUserTeamRepository = new SystemUserTeamRepository();
            SystemUserTeam           systemUserTeam           = new SystemUserTeam();

            systemUserTeam.TeamId         = teamId;
            systemUserTeam.SystemUserGuid = id;

            //Get SystemUser
            SystemUser systemUser = new SystemUser();

            systemUser = systemUserRepository.GetUserBySystemUserGuid(id);

            //Check Exists
            if (systemUser == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }
            //AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTeam(teamId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            systemUserRepository.DeleteTeam(systemUserTeam);

            //Return
            ViewData["NewSortOrder"] = 0;
            return(RedirectToAction("ListTeams", new { id = systemUserTeam.SystemUserGuid }));
        }