// using Microsoft.AspNetCore.Mvc; // using Microsoft.EntityFrameworkCore; // using Models; // namespace backend.Controllers // { // //FIXME: This needs to be behind authorization in production // [Route("api/createaccount")] // [ApiController] // public class CreateAccountController : ControllerBase // { // private readonly IConfiguration _config; // private readonly ILogger _logger; // public CreateAccountController(IConfiguration config, ILogger logger) // { // _config = config; // _logger = logger; // } // [HttpPost] // async public Task CreateAccount([FromBody] dynamic accountInfo) // { //TODO Create a model for this request // User newUser = new User(accountInfo.username, accountInfo.email, accountInfo.password, null); // _logger.LogDebug($"New user to be added: {newUser}"); // using (var db = new PortfolioPortalDbContext()) // { // var addTask = await db.AddAsync(newUser); // await db.SaveChangesAsync(); // var newUserDb = await db.Users.FirstOrDefaultAsync(u => u.Email == newUser.Email); // // Add auths // if (addTask.State == EntityState.Added) // { // _logger.LogInformation($"User user added to database: {newUserDb}."); // return Ok($"Account created for {accountInfo.email}."); // } // else // { // _logger.LogError($"Failed to add new user to database: {newUser}!"); // return BadRequest("Failed to add account to database."); // } // } // } // } // }