コード例 #1
0
        public async Task <IActionResult> Create([Bind("ID,ProductName,Price,QuanitityPurchased,SubTotal")] MakeSales makeSales)
        {
            if (ModelState.IsValid)
            {
                _context.Add(makeSales);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(makeSales));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("ID,Name,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("ID,LastName,FirstName,Email,PhoneNo")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("ID,Name,Price,QuantityAvailable,CategoryID")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.Categories, "ID", "Name", product.CategoryID);
            return(View(product));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("ID,ProductID,QuantityPurchased,SubTotal,DatePurchased,SalesID")] SalesDetail salesDetail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(salesDetail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SalesID"] = new SelectList(_context.Sales, "ID", "ID");//salesDetail.SalesID
            return(View(salesDetail));
        }