public virtual async Task<T> Create(T obj) { _context.Add(obj); //context ja cria e retorna a entidade com id, retornar ela no obj await _context.SaveChangesAsync(); return obj; }
public async Task <IActionResult> Create([Bind("Id,UserName,PassWord,DisplayName,BirthDay,Phone,Address")] User user) { if (ModelState.IsValid) { user.CreateDate = DateTime.Now; _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }