public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Genre,Price")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,PName,PDescribe,PPrice,PNum")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(AdminProduct)));
            }
            return(View(product));
        }
        public async Task <IActionResult> Create([FromBody] PaymentInfo paymentInfo)
        {
            if (_context.PaymentInfo.ToArray().Length == 0)
            {
                paymentInfo.Id = 1;
            }
            else
            {
                paymentInfo.Id = _context.PaymentInfo.ToArray()[_context.PaymentInfo.ToArray().Length - 1].Id + 1;
            }
            _context.Add(paymentInfo);
            await _context.SaveChangesAsync();

            return(new StatusCodeResult(201));
        }