private async Task <GameState> Destroy(Data.Gamespace gamespace) { if (gamespace == null || !gamespace.CanEdit(User)) { return(null); } await _pod.DeleteAll(gamespace.GlobalId); await _gamespaceStore.Delete(gamespace.Id); return(Mapper.Map <GameState>(gamespace)); }
public async Task Delete(string id, bool sudo) { var ctx = await LoadContext(id); await _pod.DeleteAll(id); if (!sudo && !ctx.Gamespace.AllowReset) { throw new ActionForbidden(); } await _store.Delete(ctx.Gamespace.Id); }
public async Task Destroy(string globalId) { var gamespace = await _gamespaceStore.Load(globalId); if (gamespace == null) { throw new InvalidOperationException(); } await _pod.DeleteAll(gamespace.GlobalId); await _gamespaceStore.Delete(gamespace.Id); }
public async Task Destroy(string globalId) { await _pod.DeleteAll(globalId); var gamespace = await _gamespaceStore.Load(globalId); if (gamespace == null) { return; } await _gamespaceStore.Delete(gamespace.Id); }
public async Task <GameState> Destroy(int id) { var gamespace = await _gamespaceStore.Load(id); if (gamespace == null || !gamespace.CanEdit(User)) { throw new InvalidOperationException(); } await _pod.DeleteAll(gamespace.GlobalId); await _gamespaceStore.Delete(id); return(Mapper.Map <GameState>(gamespace)); }
/// <summary> /// Delete all existing gamespaces of a workspace. /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <GameState[]> KillGames(string id) { var gamespaces = await _store.LoadActiveGamespaces(id); foreach (var gamespace in gamespaces) { await _pod.DeleteAll(gamespace.Id); await _gamespaceStore.Delete(gamespace.Id); } return(Mapper.Map <GameState[]>( Mapper.Map <GameStateSummary[]>(gamespaces) )); }
/// <summary> /// Delete all existing gamespaces of a workspace. /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <GameState[]> KillGames(int id) { var workspace = await _workspaceStore.LoadWithGamespaces(id); if (workspace == null || !workspace.CanEdit(User)) { throw new InvalidOperationException(); } var result = workspace.Gamespaces.ToArray(); foreach (var gamespace in result) { await _pod.DeleteAll(gamespace.GlobalId); await _gamespaceStore.Delete(gamespace.Id); } return(Mapper.Map <GameState[]>(result)); }