Beispiel #1
0
        public PartialViewResult Count(FormCollection form)
        {
            string MemberSubscriptionTypeid = form["MemberSubscriptionType"].ToString().Trim();
            string AgeGroups = form["AgeGroup"].ToString();
            string Countryid = form["Country"].ToString().Trim();
            string Stateid   = string.IsNullOrEmpty(form["State"])? string.Empty : form["State"].ToString().Trim();
            string Ethnicity = form["Ethnicity"].ToString();
            string Gender    = form["Gender"].ToString();

            var Predicates = "";

            if (!string.IsNullOrEmpty(MemberSubscriptionTypeid))
            {
                Predicates += " AND MemberSubscriptionTypeid >= " + MemberSubscriptionTypeid + "";
            }
            if (!string.IsNullOrEmpty(AgeGroups))
            {
                string[] Ages  = AgeGroups.Split('-');
                int      Left  = Convert.ToInt32(Ages[0]);
                int      Right = Convert.ToInt32(Ages[1]);

                var leftLimit  = (DateTime.Now.AddYears(-Right)).Date;
                var RightLimit = (DateTime.Now.AddYears(-Left)).Date;


                Predicates += " AND DateOfBirth Between '" + leftLimit.ToString("yyyy-MM-dd") + "' AND '" + RightLimit.ToString("yyyy-MM-dd") + "'";
            }



            if (!Countryid.Equals("0"))
            {
                Predicates += " AND Countryid = " + Convert.ToInt32(Countryid);
            }

            if (!string.IsNullOrEmpty(Stateid) && !Stateid.Equals("0"))
            {
                Predicates += " AND StateID in ( " + (Stateid) + ")";
            }
            if (!string.IsNullOrEmpty(Ethnicity))
            {
                Predicates += " AND Ethnicity = '" + Ethnicity + "'";
            }
            if (!string.IsNullOrEmpty(Gender))
            {
                Predicates += " AND Gender = '" + Gender + "'";
            }
            //TODO select count
            var SQL = "SELECT * FROM MEMBER WHERE 1=1 " + Predicates.ToString();

            using (var context = new VaultLifeApplicationEntities())
            {
                var MembersCount = context.Members.SqlQuery(SQL).ToList();
                ViewBag.number = MembersCount.Count();
            }



            return(PartialView("_MemberCount"));
        }
Beispiel #2
0
        public GameEntity(VaultLifeApplicationEntities db, IScheduler scheduler, Game game)
        {
            this.scheduler = scheduler;
            this.db        = db;
            this.rules     = new List <IRule>();
            this.game      = game;
            //  ProductInGame prod = game.ProductInGames.First();
            this.numWinnersLeft = game.NumberOfWinners;  //prod.Quantity;


            switch (game.GameState)
            {
            case "ACTIVE": this.state = GameState.ACTIVE;
                break;

            case "READY": this.state = GameState.READY;
                break;

            case "CREATED": this.state = GameState.CREATED;
                break;

            case "COMPLETED": this.state = GameState.COMPLETED;
                break;

            case "RELEASED": this.state = GameState.RELEASED;
                break;

            case "PREPARE": this.state = GameState.PREPARE_ACTIVE;
                break;
            }
        }
Beispiel #3
0
 public FCFGame(VaultLifeApplicationEntities db, IScheduler scheduler, Game game) : base(db, scheduler, game)
 {
     if (!game.GameType.GameTypeName.Equals("FCF"))
     {
         throw new InvalidOperationException();
     }
 }
Beispiel #4
0
 //TODO what does applicationUserManager do ?
 public AccountService(VaultLifeApplicationEntities db, ApplicationUserManager userManager)
 {
     this.db               = db;
     this.memberDao        = new MemberDao(db);
     this.memberSubTypeDao = new MembershipSubscriptionTypeDao(db);
     this.userManager      = userManager;
 }
Beispiel #5
0
        public GameEntity(VaultLifeApplicationEntities db, IScheduler scheduler, int numWinners)
        {
            state               = GameState.CREATED;
            this.db             = db;
            this.scheduler      = scheduler; // StdSchedulerFactory.GetDefaultScheduler();
            this.rules          = new List <IRule>();
            this.numWinnersLeft = numWinners;
            this.game           = new Game();
            switch (game.GameState)
            {
            case "ACTIVE":     this.state = GameState.ACTIVE;
                break;

            case "READY":      this.state = GameState.READY;
                break;

            case "CREATED":    this.state = GameState.CREATED;
                break;

            case "COMPLETED":  this.state = GameState.COMPLETED;
                break;

            case "RELEASED":   this.state = GameState.RELEASED;
                break;

            case "PREPARE":    this.state = GameState.PREPARE_ACTIVE;
                break;
            }
        }
Beispiel #6
0
        public FFFGame(VaultLifeApplicationEntities db, IScheduler scheduler, Game game)
            : base(db, scheduler, game)
        {
//            if (!game.GameType.GameTypeName.Equals("FastestFinger"))
//           {
//               throw new InvalidOperationException();
//          }
        }
Beispiel #7
0
        public static Member GetLoggedInMember(string UserName, VaultLifeApplicationEntities db)
        {
            var members = db.Members.Include(x => x.MemberSubscriptionType).Where(s => s.EmailAddress == UserName);

            if (members != null && members.Count() > 0)
            {
                return(members.First());
            }
            return(null);
        }
Beispiel #8
0
        public static GameEntity toGameEntity(VaultLifeApplicationEntities db, IScheduler scheduler, Game game)
        {
            switch (game.GameType.GameTypeName)
            {
            case "FastestFinger": return(new FFFGame(db, scheduler, game));

            case "FCF": return(new FCFGame(db, scheduler, game));
            }
            throw new NotImplementedException();
        }
Beispiel #9
0
        public ActionResult Pay([Bind(Include = "type")] int?type)
        {
            int ty = type == null ? 1 : (int)type;
            UpgradePaymentViewModel       model = new UpgradePaymentViewModel();
            VaultLifeApplicationEntities  db    = new VaultLifeApplicationEntities();
            MembershipSubscriptionTypeDao dao   = new MembershipSubscriptionTypeDao(db);
            MemberSubscriptionType        mst   = dao.findAll().Where(t => t.MemberSubscriptionTypeID == ty).First();

            model.MembershipSubscriptionType = ty;
            model.amount = mst.amount.ToString("#######");;
            model.MembershipSubscriptionCode = mst.MemberSubscriptionTypeCode;
            return(View("Pay", model));
        }
Beispiel #10
0
        public ActionResult Index(int imageId)
        {
            VaultLifeApplicationEntities db = new VaultLifeApplicationEntities();
            //This is my method for getting the image information
            // including the image byte array from the image column in
            // a database.
            Imagedetail image = db.Imagedetails.Where(x => x.ImageID == imageId).First();
            //As you can see the use is stupid simple.  Just get the image bytes and the
            //  saved content type.  See this is where the contentType comes in real handy.
            ImageResult result = new ImageResult(image.ImageContent, image.ContentType);

            return(result);
        }
Beispiel #11
0
        private bool UniqueName(Product product, string name)
        {
            VaultLifeApplicationEntities _db = new VaultLifeApplicationEntities();
            var dbProduct = _db.Products
                            .Where(x => x.ProductSKUCode.ToLower() == name.ToLower())
                            .FirstOrDefault();

            if (dbProduct == null)
            {
                return(true);
            }

            return(dbProduct.ProductID == product.ProductID);
        }
Beispiel #12
0
        private bool AvailableSOHCheck(ProductInGame productInGame, int newQuantity)
        {
            VaultLifeApplicationEntities _db = new VaultLifeApplicationEntities();
            var dbProduct = _db.Products
                            .Where(x => x.ProductID == productInGame.ProductID)
                            .SingleOrDefault();

            if (dbProduct == null)
            {
                return(false);
            }

            return((dbProduct.AvailableSOH - newQuantity) >= 0);
        }
Beispiel #13
0
        private bool Unique(Voucher v, string vnum)
        {
            VaultLifeApplicationEntities _db = new VaultLifeApplicationEntities();
            var dbVoucher = _db.Vouchers
                            .Where(x => x.VoucherNumber.ToLower() == vnum.ToLower())
                            .SingleOrDefault();

            if (dbVoucher == null)
            {
                return(true);
            }

            return(dbVoucher.VoucherID == v.VoucherID);
        }
Beispiel #14
0
        private bool UniqueName(Member member, string name)
        {
            VaultLifeApplicationEntities _db = new VaultLifeApplicationEntities();
            var dbMember = _db.Members
                           .Where(x => x.EmailAddress.ToLower() == name.ToLower())
                           .SingleOrDefault();

            if (dbMember == null)
            {
                return(true);
            }

            return(dbMember.MemberID == member.MemberID);
        }
Beispiel #15
0
        private bool Unique(SerialNumber sn, string snum)
        {
            VaultLifeApplicationEntities _db = new VaultLifeApplicationEntities();
            var dbSerial = _db.SerialNumbers
                           .Where(x => x.Serial.ToLower() == snum.ToLower())
                           .SingleOrDefault();

            if (dbSerial == null)
            {
                return(true);
            }

            return(dbSerial.SerialNumberID == sn.SerialNumberID);
        }
Beispiel #16
0
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            if (bundle.JobDetail.JobType == typeof(EmailSendingJob))
            {
                return(new EmailSendingJob());
            }
            VaultLifeApplicationEntities db = new VaultLifeApplicationEntities();
            JobDataMap     map         = bundle.JobDetail.JobDataMap;
            Game           game        = db.Games.Find(Convert.ToInt32(map["gameId"]));
            DateTimeOffset executeTime = DateTimeOffset.Parse((String)map["executeTime"]);
            GameRule       gameRule;

            switch (map.GetString("ruleType"))
            {
            case "NOTIFY_PARTICIPANTS":
                gameRule = game.GameRules.First(g => g.GameRuleCode.Equals("NotifiyGameParticipants"));
                return(new NotifyGameParticipantsRule(gameRule, GameEntity.toGameEntity(db, scheduler, game)));

            case "START_GAME":
                gameRule = game.GameRules.First(g => g.GameRuleCode.Equals("StartGame"));
                return(new StartGameRule(gameRule, GameEntity.toGameEntity(db, scheduler, game)));

            case "PREPARE_GAME":
                gameRule = game.GameRules.First(g => g.GameRuleCode.Equals("PrepareGameRule"));
                return(new PrepareGameRule(gameRule, GameEntity.toGameEntity(db, scheduler, game)));

            case "RESOLVE_WINNERS":
                gameRule = game.GameRules.First(g => g.GameRuleCode.Equals("ResolvePotentialWinners"));
                return(new ResolvePotentialWinners(gameRule, GameEntity.toGameEntity(db, scheduler, game)));

            case "RESOLVE_ACTUAL_WINNERS":
                gameRule = game.GameRules.First(g => g.GameRuleCode.Equals("ResolveActualWinners"));
                return(new ResolveActualWinners(gameRule, GameEntity.toGameEntity(db, scheduler, game)));

            case "START_NEW_GAME":
                gameRule = game.GameRules.First(g => g.GameRuleCode.Equals("StartNewGame"));
                return(new StartNewGameRule(gameRule, GameEntity.toGameEntity(db, scheduler, game), GameEntity.toGameEntity(db, scheduler, db.Games.Find(map["newGameId"]))));
            }
            throw new NotImplementedException();
        }
Beispiel #17
0
        private bool HaveOneLocation(ProductInGame product, int ProductInGameID)
        {
            VaultLifeApplicationEntities _db = new VaultLifeApplicationEntities();
            var dbProductInGame = _db.ProductInGames.Include(a => a.ProductLocations).Where(x => x.ProductInGameID == ProductInGameID).SingleOrDefault();

            if (dbProductInGame == null)
            {
                return(false);
            }

            if (dbProductInGame.ProductLocations == null)
            {
                return(false);
            }

            if (dbProductInGame.ProductLocations.Count <= 0)
            {
                return(false);
            }

            return(true);
        }
Beispiel #18
0
        public ActionResult Pay([Bind(Include = "MembershipSubscriptionType,PaymentsModel")] UpgradePaymentViewModel paymentViewModel)
        {
            Vaultlife.Service.PaymentService paymentService = new Vaultlife.Service.PaymentService(new VaultLifeApplicationEntities());
            string custIp  = Request.ServerVariables["REMOTE_ADDR"];
            bool   success = paymentService.pay(paymentViewModel.PaymentsModel, paymentViewModel.MembershipSubscriptionType, User.Identity.Name, this.GetIPAddress(), custIp);

            if (success)
            {
                return(Redirect("/?l=" + paymentViewModel.MembershipSubscriptionType));
            }
            else
            {
                ModelState.AddModelError("ErrorMessage", "There was an error processing your payment");

                // MemberSubscriptionTypeCode and Amount not included in POST, use MembershipSubscriptionType to do lookup and populate paymentViewModel
                VaultLifeApplicationEntities  db  = new VaultLifeApplicationEntities();
                MembershipSubscriptionTypeDao dao = new MembershipSubscriptionTypeDao(db);
                MemberSubscriptionType        mst = dao.findAll().Where(t => t.MemberSubscriptionTypeID == paymentViewModel.MembershipSubscriptionType).First();
                paymentViewModel.amount = mst.amount.ToString("#######");;
                paymentViewModel.MembershipSubscriptionCode = mst.MemberSubscriptionTypeCode;

                return(View("Pay", paymentViewModel));
            }
        }
Beispiel #19
0
 //TODO what does applicationUserManager do ?
 public AccountService(VaultLifeApplicationEntities db)
 {
     this.db               = db;
     this.memberDao        = new MemberDao(db);
     this.memberSubTypeDao = new MembershipSubscriptionTypeDao(db);
 }
 public RestartGameRule(Game game, VaultLifeApplicationEntities db)
 {
     this.game = game;
     this.db   = db;
 }
Beispiel #21
0
 public UserService(VaultLifeApplicationEntities db, ApplicationUserManager userManager)
 {
     this.userManager = userManager;
     this.db          = db;
 }
Beispiel #22
0
 public GameDao(VaultLifeApplicationEntities db)
 {
     this.db = db;
 }
Beispiel #23
0
 public TransactionDao(VaultLifeApplicationEntities db)
 {
     this.db = db;
 }
Beispiel #24
0
 public AddressService(VaultLifeApplicationEntities db)
 {
     this.db = db;
 }
Beispiel #25
0
 public GameService(VaultLifeApplicationEntities db)
 {
     this.db = db;
 }
Beispiel #26
0
 public MemberDao(VaultLifeApplicationEntities dbEntities)
 {
     this.db = dbEntities;
 }
Beispiel #27
0
 public MembershipSubscriptionTypeDao(VaultLifeApplicationEntities dbEntities)
 {
     this.db = dbEntities;
 }
Beispiel #28
0
        public PartialViewResult Insert(FormCollection form)
        {
            string Gameid = form["Game"].ToString();
            string MemberSubscriptionTypeid = form["MemberSubscriptionType"].ToString().Trim();
            string AgeGroups = form["AgeGroup"].ToString();
            string Countryid = form["Country"].ToString().Trim();
            string Stateid   = string.IsNullOrEmpty(form["State"]) ? string.Empty : form["State"].ToString().Trim();
            string Ethnicity = form["Ethnicity"].ToString();
            string Gender    = form["Gender"].ToString();

            var Predicates = "";

            if (!string.IsNullOrEmpty(MemberSubscriptionTypeid))
            {
                Predicates += "AND MemberSubscriptionTypeid >= " + MemberSubscriptionTypeid + "";
                ///TODO hmmm wrong....
            }


            if (!string.IsNullOrEmpty(AgeGroups))
            {
                string[] Ages  = AgeGroups.Split('-');
                int      Left  = Convert.ToInt32(Ages[0]);
                int      Right = Convert.ToInt32(Ages[1]);

                var leftLimit  = (DateTime.Now.AddYears(-Right)).Date;
                var RightLimit = (DateTime.Now.AddYears(-Left)).Date;


                Predicates += " AND DateOfBirth Between '" + leftLimit.ToString("yyyy-MM-dd") + "' AND '" + RightLimit.ToString("yyyy-MM-dd") + "'";
            }


            if (!Countryid.Equals("0"))
            {
                Predicates += " AND Countryid = " + Convert.ToInt32(Countryid);
            }

            if (!string.IsNullOrEmpty(Stateid) && !Stateid.Equals("0"))
            {
                Predicates += " AND StateID in ( " + (Stateid) + ")";
            }
            if (!string.IsNullOrEmpty(Ethnicity))
            {
                Predicates += " AND Ethnicity = '" + Ethnicity + "'";
            }
            if (!string.IsNullOrEmpty(Gender))
            {
                Predicates += " AND Gender = '" + Gender + "'";
            }

            var SQL = " DELETE FROM MEMBERINGAME WHERE GAMEID = " + Gameid + "; INSERT INTO MEMBERINGAME (GameId,MemberID,CountryID,StateID,CityID,MemberSubscriptionTypeID,DateInserted,DateUpdated,USR,Winindicator,PaymentIndicator) SELECT " + Gameid + ", MemberId , Countryid,Stateid,0, MemberSubscriptionTypeid,'" + DateTime.Now + "','" + DateTime.Now + "','USR' ,0,0  FROM MEMBER WHERE 1=1" + Predicates.ToString();

            using (var context = new VaultLifeApplicationEntities())
            {
                var noOfRowInserted = context.Database.ExecuteSqlCommand(SQL);
                ViewBag.number = noOfRowInserted;
            }

            if (Countryid.Equals("0"))
            {
                int  id   = Convert.ToInt32(Gameid);
                Game game = db.Games.Where(g => g.GameID == id).First();
                game.Global = true;
                db.SaveChanges();
            }

            return(PartialView("_MemberInGameSuccess"));
        }
Beispiel #29
0
 public PaymentService(VaultLifeApplicationEntities dbEntities)
 {
     this.db                  = dbEntities;
     this.memberDao           = new MemberDao(db);
     this.subscriptionTypeDao = new MembershipSubscriptionTypeDao(db);
 }