//
        // GET: /Board/Details/5
        public ActionResult Details(int id)
        {
            string currUser = User.Identity.Name;
            if(_repo.GetBoard(id)==null)return new HttpNotFoundResult("O quadro não existe");
            BoardDetailsDTO dto = new BoardDetailsDTO();

            if (_repo.InitializeBoardDetailsDTO(id, currUser, ref dto))
            {
                ViewData["users"] = _userRepo.GetAllUserList();
                return View(dto);
            }

            return new HttpUnauthorizedResult("Não tem permissão para editar este quadro");
        }
        //
        // GET: /Board/Edit/5
        public ActionResult Edit(int id)
        {
            string currUser = User.Identity.Name;
            if (_repo.GetBoard(id) == null) return new HttpNotFoundResult("O quadro não existe");
            if (!_userRepo.HasBoard(id, currUser)) return new HttpUnauthorizedResult("Não tem acesso a este quadro");
            BoardDetailsDTO dto= new BoardDetailsDTO();

            if (_userRepo.BoardOnlyVis(id,currUser))
            {
                dto.IsOwned = false;
                dto.IsVisual = true;
                dto.SingleBoard = _userRepo.GetVis(id,currUser);
            }
            else if (_userRepo.BoardOnlyEdit(id,currUser))
            {
                dto.IsOwned = false;
                dto.IsVisual = false;
                dto.SingleBoard = _userRepo.GetEdit(id,currUser);
            }
            else
            {
                dto.IsOwned = true;
                dto.IsVisual = false;
                dto.SingleBoard = new Pair(currUser, _repo.GetBoard(id));
            }
            dto.BoardLists = _repo.GetAllListsExceptArchive(id);
            ViewData["userBoardsName"] = _userRepo.AllUserBoardsNames(currUser);
            return View(dto);
        }
        public bool InitializeBoardDetailsDTO(int id, string currUser, ref BoardDetailsDTO dto)
        {
            IUserRepository _userRepo = RepoLocator.GetUsers();
            if (_userRepo.IsUserBoard(id, currUser) || _userRepo.BoardOnlyEdit(id, currUser) ||
                _userRepo.HasBoard(id, currUser))
            {

                if (_userRepo.BoardOnlyVis(id, currUser))
                {
                    dto.IsOwned = false;
                    dto.IsVisual = true;
                    dto.SingleBoard = _userRepo.GetVis(id, currUser);
                }
                else if (_userRepo.BoardOnlyEdit(id, currUser))
                {
                    dto.IsOwned = false;
                    dto.IsVisual = false;
                    dto.SingleBoard = _userRepo.GetEdit(id, currUser);
                }
                else
                {
                    dto.IsOwned = true;
                    dto.IsVisual = false;
                    dto.SingleBoard = new Pair(currUser, GetBoard(id));
                }
                dto.BoardLists = GetAllListsExceptArchive(id);
                dto.BoardCards = ShowListsAndCards(id);

                return true;
            }
            return false;
        }