Пример #1
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,Name,Description,Order")] ActivityGroup activityGroup)
        {
            if (id != activityGroup.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(activityGroup);
                    await _context.SaveChangesAsync();

                    _cache.Remove(nameof(ActivityGroup));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ActivityGroupExists(activityGroup.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(activityGroup));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,Order")] ActivityGroup activityGroup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(activityGroup);
                await _context.SaveChangesAsync();

                _cache.Remove(nameof(ActivityGroup));
                return(RedirectToAction(nameof(Index)));
            }
            return(View(activityGroup));
        }