public override async Task <bool> CreateUserAsync(ZNxt.Net.Core.Model.UserModel user, bool sendEmail = true) { if (user != null && !IsExists(user.user_id)) { if (user.roles == null) { user.roles = new List <string>(); } var roles = new List <string>() { "user", "init_user" }; roles.AddRange(user.roles); user.roles = roles.Distinct().ToList(); user.salt = CommonUtility.RandomString(10); var userObject = JObject.Parse(JsonConvert.SerializeObject(user)); userObject[CommonField.IS_ENABLED] = true; if (_dBService.WriteData(Collection.USERS, userObject)) { var userInfo = new JObject(); userInfo[CommonField.DISPLAY_ID] = CommonUtility.GetNewID(); userInfo[CommonField.USER_ID] = user.user_id; var result = _dBService.WriteData(Collection.USER_INFO, userInfo); if (result) { if (sendEmail) { await _userNotifierService.SendWelcomeEmailAsync(user); } } else { userObject[CommonField.IS_ENABLED] = false; _dBService.Write(Collection.USERS, userObject, "{user_id: '" + user.user_id + "'}"); _logger.Error($"Error while creating user user_id : {user.user_id} Type: {user.user_type}, email:{user.email}"); } return(result); } else { return(false); } } return(false); }
public override bool CreateUser(ZNxt.Net.Core.Model.UserModel user, bool sendEmail = true) { return(CreateUserAsync(user, sendEmail).GetAwaiter().GetResult()); }
public abstract Task <bool> CreateUserAsync(ZNxt.Net.Core.Model.UserModel user, bool sendEmail = true);