예제 #1
0
        public IList<Package> GetPurchasedPackages(UserInfo user)
        {
            IList<Package> packages = new List<Package>();

            UserPackageDao dao = new UserPackageDao();
            PackageDao packageDao = new PackageDao();

            IList<UserPackage> ups = dao.FindByUserAndPackage(user.Guid);
            foreach (UserPackage up in ups)
            {
                Package package = packageDao.FindByPackageGuid(up.PackageGuid);
                if (package != null)
                    packages.Add(package);
            }

            return packages;
        }
예제 #2
0
        public Boolean IsPackageValidForUser(Data.Guid userGuid, Data.Guid packageGuid)
        {
            UserPackageDao dao = new UserPackageDao();
            UserPackage package = dao.FindByUserAndPackage(userGuid, packageGuid);

            return (package != null);
        }
예제 #3
0
        public void AddToUser(Data.Guid userGuid, Package package)
        {
            //Make sure this package isn't already assocaited
            UserPackageDao dao = new UserPackageDao();

            UserPackage userPackage = dao.FindByUserAndPackage(userGuid, package.Guid);
            if (userPackage == null)
            {
                userPackage = new UserPackage();
                userPackage.UserGuid = userGuid.Value;
                userPackage.PackageGuid = package.Guid;
                userPackage.PackageTitle = package.Title;
                userPackage.PackageType = package.PackageTypeString;

                using (Transaction tx = new Transaction())
                {
                    dao.Save<UserPackage>(userPackage);
                    tx.Commit();
                }
            }
        }