Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Content,CardCategoryId,SysUserId,CreateTime,UpdateTime")] Card card)
        {
            if (id != card.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(card);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CardExists(card.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["CardCategoryId"] = new SelectList(_context.CardCategory, "Id", "CategoryName", card.CardCategoryId);
            ViewData["SysUserId"]      = new SelectList(_context.SysUsers, "Id", "UserCode", card.SysUserId);
            return(View(card));
        }
Exemplo n.º 2
0
 public bool Update(CardCategory model)
 {
     try
     {
         model.UpdateTime = DateTime.Now;
         _context.Update(model);
         _context.SaveChangesAsync();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }