protected override async Task ExecuteAsync(IConsole console) { if (Name != default && Id != default) { await ErrorAsync("Please specify either name or id, not both"); return; } var user = Name != default ? await ServerAccessor.GetUserByNameAsync(Name) : Id != default ? await ServerAccessor.GetUserByIdAsync(Id) : await ClientAccessor.GetCurrentUserAync(); if (user == null) { await WarnLineAsync("User not found"); return; } var miners = Name != default ? await ServerAccessor.ListMinersByNameAsync(Name) : Id != default ? await ServerAccessor.ListMinersByIdAsync(Id) : await ClientAccessor.ListOwnedMinersAsync(); await InfoLineAsync($" [ {user.Name} | User Info ] "); await InfoLineAsync($"[ID] | {user.Id}"); await InfoLineAsync($"[Miner Count] | {user.MinerState.MinerCount}"); await InfoLineAsync($"[Plot Count] | {user.MinerState.PlotCount}"); await InfoLineAsync($"[Plot Minutes] | {user.MinerState.PlotMinutes}"); await WriteLineAsync(); await InfoLineAsync($" [ {user.Name} | Miner Info ] "); if (miners.Count == 0) { await WarnLineAsync("None"); return; } int idLength = miners.Max(x => x.Id.ToString().Length) + 2; int nameLength = miners.Max(x => x.Name.Length); await InfoLineAsync($"Id{Space(idLength)}Name{Space(nameLength)}PM"); foreach (var miner in miners) { await WriteLineAsync($"{miner.Id} {miner.Name} {miner.PlotMinutes}"); } }
protected override async Task ExecuteAsync(IConsole console) { if (Name != default && Id != default) { await ErrorAsync("Please specify either name or id, not both"); return; } var user = Name != default ? await ServerAccessor.GetUserByNameAsync(Name) : Id != default ? await ServerAccessor.GetUserByIdAsync(Id.Value) : await MinerAccessor.GetCurrentUserAync(); if (user == null) { await WarnLineAsync("User not found"); return; } var miners = Name != default ? await ServerAccessor.ListMinersByOwnerNameAsync(Name) : Id != default ? await ServerAccessor.ListMinersByOwnerIdAsync(Id.Value) : await MinerAccessor.ListOwnedMinersAsync(); var plotters = Name != default ? await ServerAccessor.ListPlottersByOwnerNameAsync(Name) : Id != default ? await ServerAccessor.ListPlottersByOwnerIdAsync(Id.Value) : await MinerAccessor.ListOwnedPlottersAsync(); await InfoLineAsync($"[ {user.Name} | User Info ] "); await InfoLineAsync($"[ID] | {user.Id}"); await InfoLineAsync($"[Plot Minutes] | {user.PlotMinutes}"); await InfoLineAsync($"[Miner Count] | {miners.Count}"); await InfoLineAsync($"[Mining Profit] | {miners.Sum(x => x.Earnings)}"); await InfoLineAsync($"[Plotter Count] | {plotters.Count}"); await InfoLineAsync($"[Plotting Profit] | {plotters.Sum(x => x.Earnings)}"); await WriteLineAsync(); await InfoLineAsync($"[ {user.Name} | Miners ] "); if (miners.Count == 0) { await WarnLineAsync("--- No Entries ---"); } else { var columns = new Dictionary <string, Func <MinerInfo, object> >() {
public async Task <IActionResult> GetCurrentUserAsync() => Ok(await ServerAccessor.GetUserByNameAsync(AuthOptions.Name));