示例#1
0
        public List <Wallet> GetWalletsByUser(IUser user, IUser loggedUser)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            if (loggedUser == null)
            {
                throw new UserNotLoggedInException();
            }

            var walletDao = new WalletDAO();

            List <Wallet> walletList = new List <Wallet>();

            //IUser loggedUser = UserSession.GetInstance().GetLoggedUser();

            if (user.IsFriendWith(loggedUser))
            {
                return(walletDao.FindWalletsByUser(user));
            }

            return(walletList);
        }
        public List <Wallet> GetWalletsByUser(User user)
        {
            List <Wallet> walletList = new List <Wallet>();
            User          loggedUser = UserSession.GetInstance().GetLoggedUser();
            bool          isFriend   = false;

            if (loggedUser != null)
            {
                foreach (User friend in user.GetFriends())
                {
                    if (friend.Equals(loggedUser))
                    {
                        isFriend = true;
                        break;
                    }
                }

                if (isFriend)
                {
                    walletList = WalletDAO.FindWalletsByUser(user);
                }

                return(walletList);
            }
            else
            {
                throw new UserNotLoggedInException();
            }
        }
 public WalletService(UserSessionRepository userSessionRepository, WalletDAO walletDao)
 {
     this.userSessionRepository = userSessionRepository;
     this.walletDao             = walletDao;
 }