public async Task <AdminServerState> UpdateServerStateAsync(AdminServerState state) { try { var updated = await svc.UpdateServerStateAsync(state); log.LogInformation("Updated ServerState. ServerState:{@ServerState}", updated); return(updated); } catch (DbException db) { log.LogError("Failed to update ServerState. ServerState:{@ServerState} Code:{Code} Error:{Error}", state, db.ErrorCode, db.Message); db.MapThrow(); throw; } }
public async Task <ActionResult <AdminServerState> > Update(AdminServerState state) { try { var updated = await manager.UpdateServerStateAsync(state); return(Ok(updated)); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode)); } catch (Exception ex) { log.LogError("Failed to update AdminServerState. AdminServerState:{@AdminServerState} Error:{Error}", state, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <AdminServerState> UpdateServerStateAsync(AdminServerState state) { using (var cn = new SqlConnection(opts.ConnectionString)) { await cn.OpenAsync(); var updated = await cn.QueryFirstOrDefaultAsync <AdminServerState>( Sql.UpdateServerState, new { user = user.UUID, isUp = state.IsUp, downtimeMessage = state.DowntimeMessage, downtimeUntil = state.DowntimeUntil }, commandType : CommandType.StoredProcedure, commandTimeout : opts.DefaultTimeout); return(updated); } }