public async Task CreateAsync(CreateDowntimeRequest request) { var character = await _characterReadRepository.GetByIdAsync(request.CharacterId); var activity = await _activityReadRepository.GetByIdAsync(request.ActivityId); var costs = request.Costs .Select(p => new DowntimeCostEntity { ActivityCostKind = p.ActivityCostKind, Value = 0, Goal = p.Goal }) .ToArray(); var entity = new DowntimeEntity { Character = character, Activity = activity, Costs = costs, SharedWith = character.SharedWith.Concat(activity.SharedWith).ToArray() }; await(await _container).CreateItemAsync(await _entityMutator.CreateMetadataAsync(entity, request.SharedWith)); }
public async Task UpdateAsync(string id, UpdateCharacterRequest request) { var entity = await _readRepository.GetByIdAsync(id); var updatedEntity = new CharacterEntity { PlayerFullName = request.PlayerFullName, CharacterFullName = request.CharacterFullName, AccruedDowntimeDays = request.AccruedDowntimeDays }; await(await _container).ReplaceItemAsync( await _entityMutator.UpdateMetadataAsync(updatedEntity, entity, request.SharedWith), id ); }
public async Task <CharacterEntity> GetByIdAsync(string id) => await _readRepository.GetByIdAsync(id);