public async Task <ActionResult> Post([FromBody] TSUser tsUser) { string UserID = GlobalFunctions.CmdGetValueFromClaim(User.Claims, "UserID", 10); await TS.AddActivityLog(UserID, "post user", MethodBase.GetCurrentMethod()); GlobalFunctions.CmdDecryptEntityAsymm(tsUser); bool b = TS.DeleteExpiredEmaiedCodes().Result; string MachineID = GlobalFunctions.CmdGetValueFromClaim(User.Claims, "MachineID", 10); string IPAddress = HttpContext.Connection.RemoteIpAddress.ToString(); TSEmailedCodeEntity emailedCode = TS.FindEmaiedCode(tsUser.Email, IPAddress, MachineID).Result; if (emailedCode != null) { if (emailedCode.Code.ToLower().Equals(tsUser.EmailedCode)) { await TS.DeleteEmaiedCodes(tsUser.Email); tsUser.UserID = await TS.GetNewID("AllUsers", "LastUserID", true); tsUser.CreateDate = DateTime.Now; b = await TS.AddUser(tsUser); if (b) { await TS.UpdateSettingCounter("AllUsers", "UsersCount", true); await GlobalFunctions.NotifyAdmin("New user"); return(Ok("OK")); } else { return(Ok("Error:Can't add new user!")); } } else { return(Ok("Error:Emailed code is not correct!")); } } else { await TS.AddErrorLog("AllUsers", "EmaiedCode expected but not found", MethodBase.GetCurrentMethod()); return(Ok("Error:Server can't find emailed code to compare!")); } }
//public Startup(IConfiguration configuration, ILogger<Startup> logger) public Startup(IConfiguration configuration) { Configuration = configuration; //_logger = logger; //_logger.LogInformation("Added TodoRepository to services"); GlobalFunctions.CmdReadEncryptedSettings(); TS = new TableStorage(); bool b = TS.EnuserTables().Result; TSUserEntity demoUser = TS.FindUser("DemoUser", false, string.Empty).Result; if (demoUser is null) { TSUser newUser = new TSUser() { Email = "*****@*****.**", Password = "******", FullName = "Demo User", UserName = "******", UserID = TS.GetNewID("AllUsers", "LastUserID", true).Result, CreateDate = DateTime.Now, }; DemoUserID = newUser.UserID; b = TS.AddUser(newUser).Result; } else { DemoUserID = demoUser.PartitionKey; } b = TS.AddActivityLog("AllUser", "Server started", MethodBase.GetCurrentMethod()).Result; _timerUserUpdater = new Timer(DoWorkUserUpdater, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(10)); _timerReminder = new Timer(DoWorkReminder, null, TimeSpan.FromSeconds(1), TimeSpan.FromMinutes(1)); }