public async Task <ActionResult <User> > RegisterUser(User user) { try { if (user == null) { logger.LogDebug($"Response <{nameof(BadRequest)}>, given user is null"); return(BadRequest("User not specified")); } var userExist = await userDataModel.GetUserAsync(user.Username).ConfigureAwait(true); if (userExist == null) { await userDataModel.InsertUserAsync(user).ConfigureAwait(true); logger.LogDebug($"Response <{nameof(Ok)}>, User with username <{user.Username}> created"); return(Ok(user)); } logger.LogDebug($"Response <{nameof(Conflict)}>>, User with username <{user.Username}> already exists"); return(Conflict(user)); } catch (Exception ex) { logger.LogError(ex, GetType().Name); throw; } }
public async Task Seed() { // Add all the predefined profiles using the predefined password foreach (var profile in PredefinedData.Profiles) { await _userManager.InsertUserAsync(profile); } }