public async STT.Task <BondAgent> DeleteAsync(Guid id, CancellationToken ct) { if (!(await _authorizationService.AuthorizeAsync(_user, null, new ContentDeveloperRequirement())).Succeeded) { throw new ForbiddenException(); } var deletedBondAgent = new BondAgent(); _bondAgentStore.BondAgents.Remove(id, out deletedBondAgent); return(deletedBondAgent); }
public async STT.Task <BondAgent> UpdateAsync(Guid id, BondAgent bondAgent, CancellationToken ct) { if (!(await _authorizationService.AuthorizeAsync(_user, null, new ContentDeveloperRequirement())).Succeeded) { throw new ForbiddenException(); } var bondAgentToUpdate = _bondAgentStore.BondAgents[id]; if (bondAgentToUpdate == null) { throw new EntityNotFoundException <BondAgent>(); } if (!bondAgent.CheckinTime.HasValue) { bondAgent.CheckinTime = DateTime.UtcNow; } _bondAgentStore.BondAgents[id] = bondAgent; return(bondAgent); }
public async STT.Task <BondAgent> CreateAsync(BondAgent bondAgent, CancellationToken ct) { if (!(await _authorizationService.AuthorizeAsync(_user, null, new ContentDeveloperRequirement())).Succeeded) { throw new ForbiddenException(); } //TODO: add permissions // var BondAgentAdminPermission = await _context.Permissions // .Where(p => p.Key == PlayerClaimTypes.BondAgentAdmin.ToString()) // .FirstOrDefaultAsync(); // if (BondAgentAdminPermission == null) // throw new EntityNotFoundException<Permission>($"{PlayerClaimTypes.BondAgentAdmin.ToString()} Permission not found."); // end of TODO: if (!bondAgent.CheckinTime.HasValue) { bondAgent.CheckinTime = DateTime.UtcNow; } _bondAgentStore.BondAgents[bondAgent.VmWareUuid] = bondAgent; return(bondAgent); }