コード例 #1
0
        public async Task <IActionResult> Create([Bind("Id,CateoryName,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Surname,Address1,Address2,ZipCode,State,City,Phone,Email,RequestSend,RequestDeliveredIn")] Request request)
        {
            if (ModelState.IsValid)
            {
                _context.Add(request);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(request));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,DescriptionShort,DescriptionDetailed,Price,ImageURL,ImageThumbnaiURL,Preferred,InStock,CategoryId")] Snack snack)
        {
            if (ModelState.IsValid)
            {
                _context.Add(snack);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", snack.CategoryId);
            return(View(snack));
        }