Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "user_id,username,email,user_password,login_failures,first_name,last_name,phone,gender,birthdate,date_joined,is_employee,is_admin,is_member,is_inactive,is_locked_out,is_on_email_list,favorite_platform,favorite_category,notes")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(user);
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "publisher_id,publisher_name,contact_name,contact_phone,contact_email")] Publisher publisher)
        {
            if (ModelState.IsValid)
            {
                db.Publishers.Add(publisher);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(publisher));
        }
        public ActionResult Create([Bind(Include = "game_name,Units_Sold,Profit_Margin,Sales_Volume,Total_Profit")] Sales_Report sales_Report)
        {
            if (ModelState.IsValid)
            {
                db.Sales_Report.Add(sales_Report);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sales_Report));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "review_id,user_id,game_id,review_date,review_content,is_approved,is_deleted")] Review review)
        {
            if (ModelState.IsValid)
            {
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(review));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "province_id,province_code,province_name")] Province province)
        {
            if (ModelState.IsValid)
            {
                db.Provinces.Add(province);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(province));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "genre_id,genre_name,description")] Genre genre)
        {
            if (ModelState.IsValid)
            {
                db.Genres.Add(genre);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(genre));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "address_id,street_address,city,province_id,postal_code")] Address address)
        {
            if (ModelState.IsValid)
            {
                db.Addresses.Add(address);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.province_id = new SelectList(db.Provinces, "province_id", "province_code", address.province_id);
            return(View(address));
        }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "store_event_id,store_event_name,description,address_id,start_date,end_date,max_registrants,is_full,is_members_only,is_cancelled")] Store_Event store_Event)
        {
            if (ModelState.IsValid)
            {
                db.Store_Event.Add(store_Event);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.address_id = new SelectList(db.Addresses, "address_id", "street_address", store_Event.address_id);
            return(View(store_Event));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "credit_card_id,user_id,card_number,expiry_date,is_expired,is_flagged")] Credit_Card credit_Card)
        {
            if (ModelState.IsValid)
            {
                db.Credit_Card.Add(credit_Card);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.user_id = db.Users.Where(u => u.username == this.User.Identity.Name).FirstOrDefault().user_id;
            return(View(credit_Card));
        }
Ejemplo n.º 10
0
        public ActionResult Create([Bind(Include = "invoice_address_id,invoice_id,address_id,is_billing_address")] Invoice_Address invoice_Address)
        {
            if (ModelState.IsValid)
            {
                db.Invoice_Address.Add(invoice_Address);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.address_id = new SelectList(db.Addresses, "address_id", "street_address", invoice_Address.address_id);
            ViewBag.invoice_id = new SelectList(db.Invoices, "invoice_id", "invoice_id", invoice_Address.invoice_id);
            return(View(invoice_Address));
        }
Ejemplo n.º 11
0
        public ActionResult Create([Bind(Include = "line_item_id,invoice_id,game_id,quantity,price")] Line_Item line_Item)
        {
            if (ModelState.IsValid)
            {
                db.Line_Item.Add(line_Item);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.game_id    = new SelectList(db.Games, "game_id", "game_name", line_Item.game_id);
            ViewBag.invoice_id = new SelectList(db.Invoices, "invoice_id", "invoice_id", line_Item.invoice_id);
            return(View(line_Item));
        }
        public ActionResult Create([Bind(Include = "user_game_id,user_id,game_id,date_purchased,rating")] User_Game user_Game)
        {
            if (ModelState.IsValid)
            {
                db.User_Game.Add(user_Game);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.game_id = new SelectList(db.Games, "game_id", "game_name", user_Game.game_id);
            ViewBag.user_id = new SelectList(db.Users, "user_id", "username", user_Game.user_id);
            return(View(user_Game));
        }
Ejemplo n.º 13
0
        public ActionResult Create([Bind(Include = "wish_list_id,user_id,game_id,date_added")] Wish_List wish_List)
        {
            if (ModelState.IsValid)
            {
                db.Wish_List.Add(wish_List);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = wish_List.user_id }));
            }

            ViewBag.game_id = new SelectList(db.Games, "game_id", "game_name", wish_List.game_id);
            ViewBag.user_id = new SelectList(db.Users, "user_id", "username", wish_List.user_id);
            return(View(wish_List));
        }
Ejemplo n.º 14
0
        public ActionResult Create([Bind(Include = "user_id,address_id,address_name")] User_Address user_Address)
        {
            if (ModelState.IsValid)
            {
                db.User_Address.Add(user_Address);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.address_id = new SelectList(db.Addresses, "address_id", "street_address", user_Address.address_id);
            ViewBag.user_id    = new SelectList(db.Users, "user_id", "username", user_Address.user_id);
            return(View(user_Address));
        }
        public ActionResult Create([Bind(Include = "invoice_id,user_id,credit_card_id,invoice_date,ship_date,is_invoice_closed")] Invoice invoice)
        {
            if (ModelState.IsValid)
            {
                db.Invoices.Add(invoice);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.credit_card_id = new SelectList(db.Credit_Card, "credit_card_id", "credit_card_id", invoice.credit_card_id);
            ViewBag.user_id        = new SelectList(db.Users, "user_id", "username", invoice.user_id);
            return(View(invoice));
        }
Ejemplo n.º 16
0
        public ActionResult Create([Bind(Include = "store_event_user_id,store_event_id,user_id")] Store_Event_User store_Event_User)
        {
            if (ModelState.IsValid)
            {
                db.Store_Event_User.Add(store_Event_User);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.store_event_id = new SelectList(db.Store_Event, "store_event_id", "store_event_name", store_Event_User.store_event_id);
            ViewBag.user_id        = new SelectList(db.Users, "user_id", "username", store_Event_User.user_id);
            return(View(store_Event_User));
        }
Ejemplo n.º 17
0
        public ActionResult Create([Bind(Include = "user_id,friend_id,is_family,date_added")] Friend_List friend_List)
        {
            if (ModelState.IsValid)
            {
                db.Friend_List.Add(friend_List);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = friend_List.user_id }));
            }

            ViewBag.friend_id = new SelectList(db.Users, "user_id", "username", friend_List.friend_id);
            ViewBag.user_id   = new SelectList(db.Users, "user_id", "username", friend_List.user_id);
            return(View(friend_List));
        }
Ejemplo n.º 18
0
        public ActionResult Create([Bind(Include = "game_id,game_name,description,cost,list_price,on_hand,developer_id,publisher_id,genre_id,release_date,is_on_sale,is_discontinued,is_downloadable,is_physical_copy,image_location")] Game game)
        {
            if (ModelState.IsValid)
            {
                db.Games.Add(game);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.developer_id = new SelectList(db.Developers, "developer_id", "developer_name", game.developer_id);
            ViewBag.genre_id     = new SelectList(db.Genres, "genre_id", "genre_name", game.genre_id);
            ViewBag.publisher_id = new SelectList(db.Publishers, "publisher_id", "publisher_name", game.publisher_id);
            return(View(game));
        }
Ejemplo n.º 19
0
        [Authorize(Roles = "Customer, Admin, Employee, Member")]  //user must be logged in/registered in order to check out
        public ActionResult Checkout(int address_id, int credit_card_id)
        {
            int  user_id = db.Users.Where(u => u.username == this.User.Identity.Name).FirstOrDefault().user_id;
            Cart cart    = GetCart();

            if (cart.Items == null || cart.Items.Count() == 0)            // if there aren't any items in the cart - send back to index and show message
            {
                TempData["Message"] = "Invalid Submission: You cannot checkout without any items in your cart...";
                return(Checkout());
            }
            else
            {
                // create invoice + populate with data from select list in view
                Invoice invoice = new Invoice();
                invoice.user_id        = user_id;
                invoice.credit_card_id = credit_card_id;
                invoice.invoice_date   = DateTime.Now;

                // add invoice and save changes
                db.Invoices.Add(invoice);
                db.SaveChanges();

                // get id of most recently inserted invoice
                int invoiceNumber = db.Invoices.Max(i => i.invoice_id);

                // create invoice address based on user's selected address
                Invoice_Address invoiceAddress = new Invoice_Address();
                invoiceAddress.address_id         = address_id;
                invoiceAddress.invoice_id         = invoiceNumber;
                invoiceAddress.is_billing_address = true;
                db.Invoice_Address.Add(invoiceAddress);

                // get items in cart
                foreach (CartLineItem item in cart.Items)
                {
                    // create line items and add to db
                    Line_Item line_item = new Line_Item();
                    line_item.invoice_id = invoiceNumber;
                    line_item.game_id    = item.Game.game_id;
                    line_item.quantity   = item.Quantity;
                    line_item.price      = item.Game.list_price;
                    db.Line_Item.Add(line_item);
                    db.SaveChanges();
                }
                // clear out cart data
                Session["Cart"] = new Cart();
                return(RedirectToAction("DisplayUserInvoice", "Invoices", new { id = invoiceNumber }));
            }
        }
Ejemplo n.º 20
0
        public ActionResult Edit([Bind(Include = "user_id, username, email, login_failures, first_name, last_name, phone, gender, birthdate, date_joined, is_employee, is_admin, is_member, is_inactive, is_locked_out, is_on_email_list, favorite_platform, favorite_category, notes")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Entry(user).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("MyIndex", new { uname = this.User.Identity.Name }));
        }
Ejemplo n.º 21
0
        public ActionResult Register(User user)
        {
            if (ModelState.IsValid)
            {
                string password       = user.user_password;
                string hashedPassword = Crypto.HashPassword(password);

                user.user_password = hashedPassword;

                VideoGameStoreDBContext db = new VideoGameStoreDBContext();
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ModelState.AddModelError("", "One or more fields are invalid");
                return(View());
            }
        }