This commit is contained in:
Hillel Coren 2018-08-21 21:18:22 -07:00
parent 40b4f7ba11
commit 8d99bdb724
2 changed files with 20 additions and 1 deletions

View File

@ -188,7 +188,7 @@ else
sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/app/app_state.dart sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/app/app_state.dart
comment="STARTER: state getters - do not remove comment" comment="STARTER: state getters - do not remove comment"
code="${Module}State get ${module}State => this.dataState.${module}State;${lineBreak}" code="${Module}State get ${module}State => selectedCompanyState.${module}State;${lineBreak}"
code="${code}ListUIState get ${module}ListState => this.uiState.${module}UIState.listUIState;${lineBreak}" code="${code}ListUIState get ${module}ListState => this.uiState.${module}UIState.listUIState;${lineBreak}"
code="${code}${Module}UIState get ${module}UIState => this.uiState.${module}UIState;${lineBreak}${lineBreak}" code="${code}${Module}UIState get ${module}UIState => this.uiState.${module}UIState;${lineBreak}${lineBreak}"
sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/app/app_state.dart sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/redux/app/app_state.dart

View File

@ -40,4 +40,23 @@ class StubRepository {
return stubResponse.data; return stubResponse.data;
} }
Future<StubEntity> saveData(
CompanyEntity company, AuthState auth, StubEntity stub,
[EntityAction action]) async {
final data = serializers.serializeWith(StubEntity.serializer, stub);
dynamic response;
if (stub.isNew) {
response = await webClient.post(
auth.url + '/stubs',
company.token,
json.encode(data));
} else {
var url = auth.url + '/stubs/' + stub.id.toString();
if (action != null) {
url += '?action=' + action.toString();
}
response = await webClient.put(url, company.token, json.encode(data));
}
} }