public void CreateCustomer(Library.Model.Customer customer)
        {
            var newCustomer = new Entities.Customer
            {
                FirstName = customer.FirstName,
                LastName  = customer.LastName,
                UserName  = customer.UserName,
                City      = customer.City,
                State     = customer.State
            };

            _dbContext.Add(newCustomer);
        }
Ejemplo n.º 2
0
        public bool Create(string email, string name, string password)
        {
            using (var db = new GameStoreContext())
            {
                if (db.Users.Any(u => u.Email == email))
                {
                    return(false);
                }

                var isAdmin = !db.Users.Any();

                var user = new User
                {
                    Email    = email,
                    Name     = name,
                    Password = password,
                    IsAdmin  = isAdmin
                };

                db.Add(user);
                db.SaveChanges();
            }

            return(true);
        }
        public bool Create(
            string title,
            string description,
            string image,
            decimal price,
            double size,
            string videoId,
            DateTime releaseDate)
        {
            using (var db = new GameStoreContext())
            {
                if (db.Games.Any(g => g.Title == title))
                {
                    return(false);
                }

                var game = new Game
                {
                    Title       = title,
                    Description = description,
                    Image       = image,
                    Price       = price,
                    Size        = size,
                    VideoId     = videoId,
                    ReleaseDate = releaseDate
                };

                db.Add(game);
                db.SaveChanges();
            }

            return(true);
        }
        public async Task <IActionResult> Create([Bind("GameGenreId,Name")] GameGenre gameGenre)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gameGenre);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(gameGenre));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("ID,GameImage,Title,Genre,Price,Description,UnitsInStock")] Game game)
        {
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(game));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,CategoryName,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("ID,Nombre,Direccion")] Tienda tienda)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tienda);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tienda));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("ID,CreateDate,EmailAddress")] W_Email w_Email)
        {
            if (ModelState.IsValid)
            {
                _context.Add(w_Email);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(w_Email));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("ID,Nombre,Modelo,Descripcion,Cantidad,Precio,FechaSalida,Estado,Genero,TiendaId")] Juego juego)
        {
            if (ModelState.IsValid)
            {
                _context.Add(juego);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TiendaId"] = new SelectList(_context.Tienda, "ID", "Nombre", juego.TiendaId);
            return(View(juego));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("CartId,AccountId")] Cart cart)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cart);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccountId"] = new SelectList(_context.Account, "AccountId", "AspuserId", cart.AccountId);
            return(View(cart));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("Id,Name,ShortDescription,LongDescription,Image,Price,IsFavourite,Available,CategoryId")] Game game)
        {
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "Id", game.CategoryId);
            return(View(game));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Create([Bind("CartId,ShoppingCartId,GameId,GameTitle,UnitPrice,Quantity,Total,OrderDate")] Cart cart)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cart);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameId"] = new SelectList(_context.Game, "ID", "ID", cart.GameId);
            return(View(cart));
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> Create([Bind("ID,MarcaId,Modelo,Descripcion,Cantidad,Precio,FechaSalida,Estado,TiendaId")] Consola consola)
        {
            if (ModelState.IsValid)
            {
                _context.Add(consola);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MarcaId"]  = new SelectList(_context.Marca, "ID", "Nombre", consola.MarcaId);
            ViewData["TiendaId"] = new SelectList(_context.Tienda, "ID", "Nombre", consola.TiendaId);
            return(View(consola));
        }
        public async Task <IActionResult> AddFriend(int receiverId)
        {
            // Get the sender and receiver's accountIds to create a friendlist connection
            int senderId = _context.Account.FirstOrDefault(a => a.AspuserId == User.Identity.Name).AccountId;
            // Check if a connection has already been created
            bool friendExists = _context.FriendList.FirstOrDefault(a => a.AccountId == senderId && a.FriendId == receiverId) != null;

            if (!friendExists)
            {
                // Create the connection and add it to the database
                FriendList friendList = new FriendList {
                    AccountId = senderId, FriendId = receiverId
                };
                _context.Add(friendList);
                await _context.SaveChangesAsync();
            }

            // View the reciever's profile page
            var profile = _context.Profile.Include(a => a.Account).FirstOrDefault(p => p.AccountId == receiverId);

            return(RedirectToAction("Details", new { id = profile.ProfileId }));
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> Create([Bind("OrderId,FirstName,LastName,IdentityNo,Address,PostalCode,City,Email,Phone,Total,OrderCreationDate")] Order order)
        {
            var cart = CartLogic.GetCart(_context, HttpContext);
            await cart.SetOrderIdNo(order);

            if (ModelState.IsValid)
            {
                _context.Add(order);
                HttpContext.Session.Clear();
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction(nameof(Details), order));
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> Create([Bind("CreditId,AccountId,CardTypeId,CardNumber,CardCode,ExpireDate,CardHolder,BillingAddress,BillingPhone,CountryId,ProvinceStateId")] CreditCard creditCard)
        {
            if (ModelState.IsValid)
            {
                _context.Add(creditCard);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccountId"]       = new SelectList(_context.Account, "AccountId", "AspuserId", creditCard.AccountId);
            ViewData["CardTypeId"]      = new SelectList(_context.CardType, "CardTypeId", "CardType1", creditCard.CardTypeId);
            ViewData["CountryId"]       = new SelectList(_context.BillingCountry, "CountryId", "Name", creditCard.CountryId);
            ViewData["ProvinceStateId"] = new SelectList(_context.BillingProvinceState, "ProvinceStateId", "Name", creditCard.ProvinceStateId);
            return(View(creditCard));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> Create([Bind("GameId,GameName,GameDescription,GameDownloadLink,GamePrice,GameDiscount,GameGenreId")] Game game)
        {
            //deal with uploaded file
            string filePath = Path.GetFileNameWithoutExtension(game.GameDownloadLink);


            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameGenreId"] = new SelectList(_context.GameGenre, "GameGenreId", "Name", game.GameGenreId);
            return(View(game));
        }