public IActionResult Create(Article article) { _context.Articles.Add(article); _context.SaveChanges(); //return 123; return(CreatedAtRoute("GetArticle", new { id = article.Id }, article)); }
public TokenController(IConfiguration config, HnContext context, IConfiguration configuration) { _config = config; _context = context; int usersCount = context.Users.Count(); if (usersCount == 0) { var hashedPassword = SecurePasswordHasher.Hash(configuration["Admin:Password"]); User admin = new User { Username = configuration["Admin:Username"], Password = hashedPassword }; context.Users.Add(admin); context.SaveChanges(); } }