Esempio n. 1
0
        // GET: ProductInGames/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            ProductInGame model = db.ProductInGames.Include(x => x.ProductLocations).Where(x => x.ProductInGameID == id).First();

            model = (ProductInGame)Helpers.TableTracker.TrackEdit(model, "USR");


            if (model == null)
            {
                return(HttpNotFound());
            }

            ProductInGameViewModel productInGameViewModel = new ProductInGameViewModel {
                ProductInGame = model, CurrentQuantity = model.Quantity, ProductLocations = model.ProductLocations
            };

            ViewBag.ProductOwnerID = new SelectList(db.Owners, "OwnerID", "OwnerCode");
            ViewBag.CurrencyID     = new SelectList(db.Currencies, "CurrencyID", "CurrencyCode", model.CurrencyID);
            ViewBag.GameID         = new SelectList(db.Games, "GameID", "GameCode", model.GameID);
            ViewBag.ProductID      = new SelectList(db.Products, "ProductID", "ProductSKUCode", model.ProductID);
            return(View(productInGameViewModel));
        }
Esempio n. 2
0
        public ActionResult DetailsComingSoon(int id)
        {
            AccountService service  = new AccountService(db, null);
            int            MemberID = 0;

            if (Request.IsAuthenticated)
            {
                MemberID = service.findMember(User.Identity.Name).MemberID;
            }

            ProductInGame pigs = db.ProductInGames.Where(x => x.GameID == id).First();

            if (pigs.Game.GameState.ToLower() == "completed")
            {
                return(Redirect("/"));
            }
            ProductDisplayViewModel pdvm = new ProductDisplayViewModel(MemberID, pigs.GameID);

            pdvm.Product = pigs.Product;
            pdvm.images  = pigs.Product.Imagedetails.Where(w => w.ImageTypeID == 3);


            //TODO: DS: What are therules for which p.i.g. to select/display here
            GameDao gd = new GameDao(db);
            List <GameListViewModel> otherGames = gd.getOtherGames(MemberID, pigs.Game.MemberSubscriptionType);

            otherGames.RemoveAll(g => g.gameID == id);
            pdvm.CurrentProductInGame = pigs;
            pdvm.otherGames           = otherGames;

            return(View(pdvm));
        }
Esempio n. 3
0
        public ActionResult ProductInGame([Bind(Include = "productID,Quantity,PriceInGame,ReferencePrice,CurrencyID")] ProductInGame data, string prevBtn, string nextBtn)
        {
            GameAdminViewModel game = GetGame();

            if (prevBtn != null)
            {
                GameAdminViewModel g = new GameAdminViewModel();
                g.Game = game.Game;

                g.Game.DateInserted = DateTime.Now;
                g.Game.DateUpdated  = DateTime.Now;
                g.Game.USR          = "******";
                return(RedirectToAction("Create", g.Game));
            }
            if (nextBtn != null)
            {
                if (ModelState.IsValid)
                {
                    game.ProductInGames             = data;
                    game.ProductInGames.DateUpdated = DateTime.Now;
                    game.ProductInGames.USR         = "******";
                    Session["game"] = game;
                    return(RedirectToAction("ProductLocation"));
                }
            }
            return(View());
        }
Esempio n. 4
0
        // GET: ProductLocations/Create
        public ActionResult Create()
        {
            ViewBag.ProductInGameID = new SelectList(db.ProductInGames, "ProductInGameID", "Currency");
            ProductInGame model = new ProductInGame();

            model = (ProductInGame)Helpers.TableTracker.TrackCreate(model, "USR");
            return(View(model));
        }
Esempio n. 5
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProductInGame productInGame = db.ProductInGames.Find(id);

            db.ProductInGames.Remove(productInGame);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 6
0
        public ActionResult CreateForGame([Bind(Include = "ProductInGameID,ProductID, ReferencePrice, PriceInGame,GameID,Quantity,CurrencyID,DateInserted,DateUpdated,USR")] ProductInGame productInGame)
        {
            ProductInGameValidator validator = new ProductInGameValidator();

            if (ModelState.IsValid)
            {
                //Deduct quantity from Product table if stock available
                //@Patrick 6) Depletes the product Quantity from the "Available Stock" amount on the Product record.
                //Available Stock must not go negative (Validator checks for this)
                //Get Product
                var product = db.Products.Where(x => x.ProductID == productInGame.ProductID).First();
                //Deplete available stock on hand
                product.AvailableSOH -= productInGame.Quantity;


                //Save
                if (product.AvailableSOH >= 0)
                {
                    db.Entry(product).State = EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    ModelState.AddModelError("QuantityError", "Not enough stock on hand for this product");
                    ViewBag.CurrencyID = new SelectList(db.Currencies, "CurrencyID", "CurrencyCode", productInGame.CurrencyID);
                    ViewBag.GameID     = new SelectList(db.Games, "GameID", "GameCode", productInGame.GameID);
                    ViewBag.ProductID  = new SelectList(db.Products, "ProductID", "ProductSKUCode", productInGame.ProductID);
                    return(View(productInGame));
                }


                db.ProductInGames.Add(productInGame);
                db.SaveChanges();


                return(RedirectToAction("EditMakeGame", "Games", new { id = productInGame.GameID }));
            }

            FluentValidation.Results.ValidationResult results = validator.Validate(productInGame);
            IList <ValidationFailure> failures = results.Errors;
            StringBuilder             sb       = new StringBuilder();

            foreach (var e in results.Errors)
            {
                ModelState.AddModelError(e.PropertyName + "Error", e.ErrorMessage);
                sb.AppendLine(e.ErrorMessage);
            }

            ViewBag.CurrencyID = new SelectList(db.Currencies, "CurrencyID", "CurrencyCode", productInGame.CurrencyID);
            ViewBag.GameID     = new SelectList(db.Games, "GameID", "GameCode", productInGame.GameID);
            ViewBag.ProductID  = new SelectList(db.Products, "ProductID", "ProductSKUCode", productInGame.ProductID);
            return(View(productInGame));
        }
Esempio n. 7
0
        // GET: ProductInGames/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductInGame productInGame = db.ProductInGames.Find(id);

            if (productInGame == null)
            {
                return(HttpNotFound());
            }
            return(View(productInGame));
        }
Esempio n. 8
0
        public ActionResult Deal(int?GameID)
        {
            if (GameID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Game game = db.Games.Find(GameID);

            if (game == null)
            {
                return(HttpNotFound());
            }
            if (game.GameState.ToUpper() == "COMPLETED")
            {
                return(RedirectPermanent("/"));
            }

            AspNetUser user   = db.AspNetUsers.Where(x => x.UserName == User.Identity.Name).First();
            Member     member = db.Members.Where(m => m.ASPUserId == user.Id).First();

            ViewBag.MemberID = member.MemberID;
            var cnt = db.MemberInGames.Count(x => x.MemberID == member.MemberID && x.GameID == GameID);

            if (cnt == 0 && game.Global != true)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));  // Throw unauth error here
            }

            ViewBag.GameState  = game.GameState;
            ViewBag.NextGameID = game.NextGameID;


            var images = db.ProductInfoes.Where(g => g.GameID == GameID);
            var image  = images.FirstOrDefault();

            ProductInGame pig     = db.ProductInGames.Where(pi => pi.GameID == GameID).First();
            Product       product = pig.Product;

            ViewBag.Description = product.ProductDescription;
            ViewBag.ProductName = product.ProductName;
            ViewBag.PriceInGame = pig.PriceInGame;
            ViewBag.OldPrice    = pig.ReferencePrice;
            ViewBag.Currency    = pig.Currency.CurrencySymbol;
            // ViewBag.PriceInGame = ViewBag.PriceInGame.Format(new CultureInfo(CultureInfo.CurrentCulture.Name), "{C}");
            ViewBag.MainImage = game.ProductInGames.First().Product.Imagedetails.First().ImageID != null ?                //TODO sort out main image stuff
                                ViewBag.MainImage = game.ProductInGames.First().Product.Imagedetails.First().ImageID : 0; //TODO sort out main image stuff

            return(View(images.ToList()));
        }
Esempio n. 9
0
        private ProductInGame toProductInGame(int productID, int GameId, decimal priceInGame, decimal referencePrice, int quantity)
        {
            ProductInGame pig = new ProductInGame();

            pig.ProductID      = productID;
            pig.GameID         = GameId;
            pig.Quantity       = quantity;
            pig.CurrencyID     = 1;
            pig.DateInserted   = DateTime.Now;
            pig.DateUpdated    = DateTime.Now;
            pig.USR            = "******";
            pig.PriceInGame    = priceInGame;
            pig.ReferencePrice = referencePrice;
            return(pig);
        }
Esempio n. 10
0
        public ActionResult DeleteConfirmed(int id)
        {
            //TODO fix delete images

            /*           var DisplayItems = db.DisplayItems.Where(x => x.ProductID == id).ToList();
             *
             *         foreach (var d in DisplayItems)
             *         {
             *             DisplayItem displayItem = db.DisplayItems.Where(s => s.DisplayItemID == d.DisplayItemID).First();
             *             db.DisplayItems.Remove(displayItem);
             *             db.SaveChanges();
             *         }
             */
            var ProductInWatchLists = db.ProductInWatchLists.Where(x => x.ProductID == id).ToList();

            foreach (var d in ProductInWatchLists)
            {
                ProductInWatchList ProductInWatchList = db.ProductInWatchLists.Where(s => s.ProductInWatchListID == d.ProductInWatchListID).First();
                db.ProductInWatchLists.Remove(ProductInWatchList);
                db.SaveChanges();
            }

            var ProductInGames = db.ProductInGames.Where(x => x.ProductID == id).ToList();

            foreach (var d in ProductInGames)
            {
                var ProductPlayeds = db.ProductPlayeds.Where(x => x.ProductInGameID == d.ProductInGameID).ToList();

                foreach (var d1 in ProductPlayeds)
                {
                    ProductPlayed ProductPlayed = db.ProductPlayeds.Where(s => s.ProductInGameID == d1.ProductInGameID).First();
                    db.ProductPlayeds.Remove(ProductPlayed);
                    db.SaveChanges();
                }

                var ProductLocations = db.ProductLocations.Where(x => x.ProductInGameID == d.ProductInGameID).ToList();

                foreach (var d1 in ProductLocations)
                {
                    var SerialNumbers = db.SerialNumbers.Where(x => x.ProductLocationID == d1.ProductLocationID).ToList();
                    foreach (var s1 in SerialNumbers)
                    {
                        SerialNumber SerialNumber = db.SerialNumbers.Where(s => s.ProductLocationID == d1.ProductLocationID).First();
                        db.SerialNumbers.Remove(SerialNumber);
                        db.SaveChanges();
                    }

                    var Vouchers = db.Vouchers.Where(x => x.ProductLocationID == d1.ProductLocationID).ToList();
                    foreach (var s1 in Vouchers)
                    {
                        Voucher Voucher = db.Vouchers.Where(s => s.ProductLocationID == d1.ProductLocationID).First();
                        db.Vouchers.Remove(Voucher);
                        db.SaveChanges();
                    }

                    ProductLocation ProductLocation = db.ProductLocations.Where(s => s.ProductInGameID == d1.ProductInGameID).First();
                    db.ProductLocations.Remove(ProductLocation);
                    db.SaveChanges();
                }


                ProductInGame ProductInGame = db.ProductInGames.Where(s => s.ProductInGameID == d.ProductInGameID).First();
                db.ProductInGames.Remove(ProductInGame);
                db.SaveChanges();
            }

            Product product = db.Products.Find(id);

            db.Products.Remove(product);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 11
0
        public string Purchase(FormCollection form)
        {
            int        GameID = Convert.ToInt32((form["GameID"]));
            AspNetUser user   = db.AspNetUsers.Where(x => x.UserName == User.Identity.Name).First();
            Member     member = db.Members.Where(m => m.ASPUserId == user.Id).First();


            MemberInGame mib = db.MemberInGames.Where(c => c.MemberID == member.MemberID && c.GameID == GameID).First();

            trackingTransactionManager.PausePaymentTrackingTransaction(GameID, member.MemberID);

            //Address billingAddress = db.Addresses.Where(a => a.MemberID == member.MemberID && a.AddressType.ToLower() == "billing").First();
            pig = mib.Game.ProductInGames.FirstOrDefault();



            /* Setcom Purchase */
            SetcomPaymentTransactionManager PayMan = new SetcomPaymentTransactionManager();
            PurchaseTransactionRequest      purchaseTransactionRequest = new PurchaseTransactionRequest();

            purchaseTransactionRequest.CCNumber            = form["PaymentsModel.CardNumber"]; //"4444444444444444";
            purchaseTransactionRequest.CCCVV               = form["PaymentsModel.CVCNumber"];
            purchaseTransactionRequest.ExYear              = (form["PaymentsModel.ExpiryDateY"].ToString().Trim().Length > 2) ? form["PaymentsModel.ExpiryDateY"] : "20" + form["PaymentsModel.ExpiryDateY"];
            purchaseTransactionRequest.ExMonth             = form["PaymentsModel.ExpiryDateM"];
            purchaseTransactionRequest.CCName              = form["PaymentsModel.NameOnCard"];
            purchaseTransactionRequest.MemberInGameID      = mib.MemberInGameID;
            purchaseTransactionRequest.EmailAddress        = mib.Member.EmailAddress;
            purchaseTransactionRequest.CC_Amount           = pig.PriceInGame.ToString();
            purchaseTransactionRequest.ip_address          = Request.ServerVariables["REMOTE_ADDR"];
            purchaseTransactionRequest.transactionDateTime = DateTime.Now;

            /* Additional Non-mandatory fields */
            purchaseTransactionRequest.bill_first_name = mib.Member.FirstName;
            purchaseTransactionRequest.bill_last_name  = mib.Member.LastName;

            purchaseTransactionRequest.bill_street1 = "";
            purchaseTransactionRequest.bill_street2 = "";
            purchaseTransactionRequest.bill_city    = "";
            purchaseTransactionRequest.bill_state   = "";
            purchaseTransactionRequest.bill_country = mib.Member.Country.CountryName;;
            purchaseTransactionRequest.bill_zip     = "";
            purchaseTransactionRequest.bill_phone   = "";
            purchaseTransactionRequest.bill_title   = "";



            PurchaseTransactionResponse ptRes = PayMan.PerformPaymentTransaction(purchaseTransactionRequest);

            ptRes.outcome = ptRes.outcome.ToUpper();
            if (ptRes.outcome.ToUpper() != "APPROVED")
            // Setcom change ends here
            {
                trackingTransactionManager.ResumePaymentTrackingTransaction(GameID, member.MemberID);
                ptRes.timeRemaining = trackingTransactionManager.GetTimeRemaining(GameID, member.MemberID).ToString();
            }
            else
            {
                trackingTransactionManager.CompletePaymentTrackingTransaction(GameID, member.MemberID);
                //Update paymentIndicator
                mib.PaymentIndicator = true;
                try
                {
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                                               ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                }


                // get winner address
                Address deliveryAddress = db.Addresses.FirstOrDefault(x => x.MemberID == member.MemberID && x.AddressType.ToLower() == "postal");

                // get quantity won - divide quantity from pig by number of winners ??? really??? ok then.....
                Game qtyGame = db.Games.Find(GameID);

                int winQuantity = 1; //pig.Quantity / qtyGame.NumberOfWinners;
                // send winner email
                this.sendWinnermail(member.FirstName + ' ' + member.LastName, member.EmailAddress, deliveryAddress, winQuantity);
            }

            JsonResult json = new JsonResult
            {
                Data = ptRes
            };

            string son = new JavaScriptSerializer().Serialize(json.Data);

            return(son);
        }
Esempio n. 12
0
        //TODO : Can be removed.
        private DateTime GetGameStart(ProductInGame CurrentProductInGame)
        {
            var gameRule = db.GameRules.Where(gr => gr.GameID == CurrentProductInGame.GameID && gr.GameRuleCode.ToLower() == "startgame");

            return(gameRule.First().ExcecuteTime);
        }