Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("GroupId,GroupName,GroupCode")] HeadGroup headGroup)
        {
            if (id != headGroup.GroupId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(headGroup);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HeadGroupExists(headGroup.GroupId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(headGroup));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("GroupId,GroupName,GroupCode")] HeadGroup headGroup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(headGroup);
                await _context.SaveChangesAsync();

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