コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("WcatId,Wcatname,Wcatnotes")] WealthCategories wealthCategories,
                                               string filter = "", int page = 1, string sortExpression = "WcatId")
        {
            ViewBag.Filter         = filter;
            ViewBag.Page           = page;
            ViewBag.SortExpression = sortExpression;

            if (id != wealthCategories.WcatId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(wealthCategories);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WealthCategoriesExists(wealthCategories.WcatId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(wealthCategories));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("WcatId,Wcatname,Wcatnotes")] WealthCategories wealthCategories,
                                                 string filter = "", int page = 1, string sortExpression = "WcatId")
        {
            ViewBag.Filter         = filter;
            ViewBag.Page           = page;
            ViewBag.SortExpression = sortExpression;

            if (ModelState.IsValid)
            {
                _context.Add(wealthCategories);
                await _context.SaveChangesAsync();

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