Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("CardID,CardNumber,SecCode,Preferred,CreatedDate,LastUpdatedDate,IsActive")] Card card)
        {
            if (ModelState.IsValid)
            {
                _context.Add(card);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(card));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("BuyerID,Name,Email,Nickname,CreatedDate,LastUpdatedDate,IsActive")] Buyer buyer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(buyer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(buyer));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("AddressID,Address1,Address2,ZipCode,City,State,Preferred,CreatedDate,LastUpdatedDate,IsActive")] Address address)
        {
            if (ModelState.IsValid)
            {
                _context.Add(address);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(address));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("BookID,Title,Author,Genre,Isbn,Seller,Price,RatingAve,Cover,CreationDate,Quantity,CreatedDate,LastUpdatedDate,IsActive")] Book book)
        {
            if (ModelState.IsValid)
            {
                book.IsActive = true;
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("SaveForLaterID,BuyerID,Date,CreatedDate,LastUpdatedDate,IsActive")] SaveForLater saveForLater)
        {
            if (ModelState.IsValid)
            {
                _context.Add(saveForLater);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BuyerID"] = new SelectList(_context.Buyers, "BuyerID", "BuyerID", saveForLater.BuyerID);
            return(View(saveForLater));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("ShoppingCartID,TotalPrice,BuyerID,CreatedDate,LastUpdatedDate,IsActive")] ShoppingCart shoppingCart)
        {
            if (ModelState.IsValid)
            {
                _context.Add(shoppingCart);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BuyerID"] = new SelectList(_context.Buyers, "BuyerID", "BuyerID", shoppingCart.BuyerID);
            return(View(shoppingCart));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("ReviewID,BuyerID,BookID,CreationDate,Ratingtxt,Rating,CreatedDate,LastUpdatedDate,IsActive")] Review review)
        {
            if (ModelState.IsValid)
            {
                _context.Add(review);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookID"]  = new SelectList(_context.Books, "BookID", "BookID", review.BookID);
            ViewData["BuyerID"] = new SelectList(_context.Buyers, "BuyerID", "BuyerID", review.BuyerID);
            return(View(review));
        }
Ejemplo n.º 8
0
        public async Task <int> AddBook(BookModel model)
        {
            var newBook = new Books()
            {
                Title       = model.Title,
                Author      = model.Author,
                Pages       = model.Pages,
                CreatedOn   = DateTime.UtcNow,
                Description = model.Description,
                UpdatedOn   = DateTime.UtcNow
            };

            await _context.Books.AddAsync(newBook);

            await _context.SaveChangesAsync();

            return(newBook.id);
        }