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

                return(RedirectToAction(nameof(Index)));
            }

            return(View(product));
        }
コード例 #2
0
        public async Task <bool> CreateAsync(Role role)
        {
            _dbContext.Add(role);
            await _dbContext.SaveChangesAsync();

            return(true);
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("Id,Type")] Role role)
        {
            if (ModelState.IsValid)
            {
                _context.Add(role);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(role));
        }