Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,IsDelete")] Type @type)
        {
            if (id != @type.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@type);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeExists(@type.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(@type));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("ID,Name,IsDelete")] Type @type)
        {
            _context.Add(@type);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));

            return(View(@type));
        }