Beispiel #1
0
        public async Task <IActionResult> Create([Bind("Id,Title,Content,CardCategoryId,SysUserId,CreateTime,UpdateTime")] Card card)
        {
            if (ModelState.IsValid)
            {
                _context.Add(card);
                await _context.SaveChangesAsync();

                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));
        }
Beispiel #2
0
 public bool Add(CardCategory model)
 {
     try
     {
         model.CreateTime = DateTime.Now;
         _context.Add(model);
         _context.SaveChangesAsync();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }