コード例 #1
0
        public async Task <IActionResult> Create([Bind("FlavourId,FlavourName,FlavourDescription")] Flavour flavour)
        {
            if (ModelState.IsValid)
            {
                _context.Add(flavour);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(flavour));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("BrandId,BrandName")] Brand brand)
        {
            if (ModelState.IsValid)
            {
                _context.Add(brand);
                await _context.SaveChangesAsync();

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("DistributorId,DistributorName,DistributorContactNo")] Distributor distributor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(distributor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(distributor));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("IceCreamId,IceCreamName,IceCreamDescription,IceCreamPrice,BrandId,FlavourId,DistributorId,CategoryId")] IceCream iceCream)
        {
            if (ModelState.IsValid)
            {
                _context.Add(iceCream);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"]       = new SelectList(_context.Brands, "BrandId", "BrandId", iceCream.BrandId);
            ViewData["CategoryId"]    = new SelectList(_context.Categories, "CategoryId", "CategoryId", iceCream.CategoryId);
            ViewData["DistributorId"] = new SelectList(_context.Distributors, "DistributorId", "DistributorId", iceCream.DistributorId);
            ViewData["FlavourId"]     = new SelectList(_context.Flavours, "FlavourId", "FlavourId", iceCream.FlavourId);
            return(View(iceCream));
        }