public async Task <IActionResult> Create([FromBody] User user) { if (user == null) { return(StatusCode(403)); } try { using (var dbContext = new ResistContext()) { User newUser = new User() { Username = user.Username }; await dbContext.Users.AddAsync(newUser); dbContext.SaveChanges(); return(Json(newUser)); } } catch { return(StatusCode(500)); } }
public IActionResult Index() { using (var dbContext = new ResistContext()) { List <User> users = dbContext.Users.ToList(); if (users == null) { users = new List <User>(); } return(Json(users)); } }
public GamesController(ResistContext context) { _context = context; }