Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,RefCategoryName")] RefCategory refCategory)
        {
            if (id != refCategory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(refCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RefCategoryExists(refCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(refCategory));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("Id,RefCategoryName")] RefCategory refCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(refCategory);
                await _context.SaveChangesAsync();

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