Added ship post/put/delete to API
This commit is contained in:
parent
88d6a6a994
commit
106247527e
1277
misc/BreCalApi.cs
1277
misc/BreCalApi.cs
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,7 @@ tags:
|
|||||||
- name: shipcall
|
- name: shipcall
|
||||||
- name: times
|
- name: times
|
||||||
- name: static
|
- name: static
|
||||||
|
- name: ship
|
||||||
paths:
|
paths:
|
||||||
/login:
|
/login:
|
||||||
post:
|
post:
|
||||||
@ -158,7 +159,7 @@ paths:
|
|||||||
summary: gets a list of ships
|
summary: gets a list of ships
|
||||||
description: Gets a list of ships including logically deleted ships to be used with shipcalls
|
description: Gets a list of ships including logically deleted ships to be used with shipcalls
|
||||||
tags:
|
tags:
|
||||||
- static
|
- ship
|
||||||
operationId: shipsGet
|
operationId: shipsGet
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
@ -175,6 +176,77 @@ paths:
|
|||||||
$ref: '#/components/responses/500'
|
$ref: '#/components/responses/500'
|
||||||
'503':
|
'503':
|
||||||
$ref: '#/components/responses/503'
|
$ref: '#/components/responses/503'
|
||||||
|
post:
|
||||||
|
summary: create a new ship entry
|
||||||
|
description: adds a new non-existing ship to the database. The ships IMO number is the unique identifier.
|
||||||
|
tags:
|
||||||
|
- ship
|
||||||
|
operationId: shipsCreate
|
||||||
|
requestBody:
|
||||||
|
description: Ship details. **Do not** provide id parameter.
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ship'
|
||||||
|
responses:
|
||||||
|
'201':
|
||||||
|
$ref: '#/components/responses/201'
|
||||||
|
'400':
|
||||||
|
$ref: '#/components/responses/400'
|
||||||
|
'401':
|
||||||
|
$ref: '#/components/responses/401'
|
||||||
|
'500':
|
||||||
|
$ref: '#/components/responses/500'
|
||||||
|
'503':
|
||||||
|
$ref: '#/components/responses/503'
|
||||||
|
put:
|
||||||
|
summary: Update a ship entry
|
||||||
|
description: Updating a ship entry. Please do not modify the IMO number. In that case please add a new entry.
|
||||||
|
tags:
|
||||||
|
- ship
|
||||||
|
operationId: shipUpdate
|
||||||
|
requestBody:
|
||||||
|
description: Updated ship entry. The id parameter is **required**.
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ship'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
$ref: '#/components/responses/200'
|
||||||
|
'400':
|
||||||
|
$ref: '#/components/responses/400'
|
||||||
|
'401':
|
||||||
|
$ref: '#/components/responses/401'
|
||||||
|
'500':
|
||||||
|
$ref: '#/components/responses/500'
|
||||||
|
'503':
|
||||||
|
$ref: '#/components/responses/503'
|
||||||
|
delete:
|
||||||
|
summary: Delete a ship (logically).
|
||||||
|
description: 'A ship can only be logically deleted, since it is possible to have been used in previous shipcalls. On logical delete, the ship can no longer be selected in a new ship call.'
|
||||||
|
tags:
|
||||||
|
- ship
|
||||||
|
operationId: shipDelete
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: query
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
$ref: '#/components/responses/200'
|
||||||
|
'400':
|
||||||
|
$ref: '#/components/responses/400'
|
||||||
|
'401':
|
||||||
|
$ref: '#/components/responses/401'
|
||||||
|
'500':
|
||||||
|
$ref: '#/components/responses/500'
|
||||||
|
'503':
|
||||||
|
$ref: '#/components/responses/503'
|
||||||
/participants:
|
/participants:
|
||||||
get:
|
get:
|
||||||
summary: gets one or all participants
|
summary: gets one or all participants
|
||||||
|
|||||||
@ -75,12 +75,12 @@ namespace BreCalClient
|
|||||||
|
|
||||||
switch (CallType)
|
switch (CallType)
|
||||||
{
|
{
|
||||||
case Extensions.TypeEnum.Incoming:
|
case ShipcallType.Arrival:
|
||||||
this.labelETA.FontWeight = FontWeights.Bold;
|
this.labelETA.FontWeight = FontWeights.Bold;
|
||||||
this.datePickerETABerth.ContextMenu.IsEnabled = false;
|
this.datePickerETABerth.ContextMenu.IsEnabled = false;
|
||||||
break;
|
break;
|
||||||
case Extensions.TypeEnum.Outgoing:
|
case ShipcallType.Departure:
|
||||||
case Extensions.TypeEnum.Shifting:
|
case ShipcallType.Shifting:
|
||||||
this.labelETD.FontWeight = FontWeights.Bold;
|
this.labelETD.FontWeight = FontWeights.Bold;
|
||||||
this.datePickerETDBerth.ContextMenu.IsEnabled = false;
|
this.datePickerETDBerth.ContextMenu.IsEnabled = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -97,12 +97,12 @@ namespace BreCalClient
|
|||||||
|
|
||||||
switch (CallType)
|
switch (CallType)
|
||||||
{
|
{
|
||||||
case Extensions.TypeEnum.Incoming:
|
case ShipcallType.Arrival:
|
||||||
this.labelStart.FontWeight = FontWeights.Bold;
|
this.labelStart.FontWeight = FontWeights.Bold;
|
||||||
this.datePickerOperationStart.ContextMenu.IsEnabled = false;
|
this.datePickerOperationStart.ContextMenu.IsEnabled = false;
|
||||||
break;
|
break;
|
||||||
case Extensions.TypeEnum.Outgoing:
|
case ShipcallType.Departure:
|
||||||
case Extensions.TypeEnum.Shifting:
|
case ShipcallType.Shifting:
|
||||||
this.labelEnd.FontWeight = FontWeights.Bold;
|
this.labelEnd.FontWeight = FontWeights.Bold;
|
||||||
this.datePickerOperationEnd.ContextMenu.IsEnabled = false;
|
this.datePickerOperationEnd.ContextMenu.IsEnabled = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -47,6 +47,7 @@ namespace BreCalClient
|
|||||||
private readonly UserApi _userApi;
|
private readonly UserApi _userApi;
|
||||||
private readonly TimesApi _timesApi;
|
private readonly TimesApi _timesApi;
|
||||||
private readonly StaticApi _staticApi;
|
private readonly StaticApi _staticApi;
|
||||||
|
private readonly ShipApi _shipApi;
|
||||||
|
|
||||||
private CancellationTokenSource _tokenSource = new();
|
private CancellationTokenSource _tokenSource = new();
|
||||||
private LoginResult? _loginResult;
|
private LoginResult? _loginResult;
|
||||||
@ -85,6 +86,8 @@ namespace BreCalClient
|
|||||||
_timesApi.Configuration.ApiKeyPrefix["Authorization"] = "Bearer";
|
_timesApi.Configuration.ApiKeyPrefix["Authorization"] = "Bearer";
|
||||||
_staticApi = new StaticApi(Properties.Settings.Default.API_URL);
|
_staticApi = new StaticApi(Properties.Settings.Default.API_URL);
|
||||||
_staticApi.Configuration.ApiKeyPrefix["Authorization"] = "Bearer";
|
_staticApi.Configuration.ApiKeyPrefix["Authorization"] = "Bearer";
|
||||||
|
_shipApi = new ShipApi(Properties.Settings.Default.API_URL);
|
||||||
|
_shipApi.Configuration.ApiKeyPrefix["Authorization"] = "Bearer";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -136,6 +139,7 @@ namespace BreCalClient
|
|||||||
this._shipcallApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._shipcallApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
this._timesApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._timesApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
this._staticApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._staticApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
|
this._shipApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
this.LoadStaticLists();
|
this.LoadStaticLists();
|
||||||
this.labelUsername.Text = $"{_loginResult.FirstName} {_loginResult.LastName}";
|
this.labelUsername.Text = $"{_loginResult.FirstName} {_loginResult.LastName}";
|
||||||
_timer = new Timer(RefreshToken, null, 4000000, Timeout.Infinite);
|
_timer = new Timer(RefreshToken, null, 4000000, Timeout.Infinite);
|
||||||
@ -177,6 +181,7 @@ namespace BreCalClient
|
|||||||
this._timesApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._timesApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
this._shipcallApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._shipcallApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
this._staticApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._staticApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
|
this._shipApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -230,11 +235,11 @@ namespace BreCalClient
|
|||||||
_tokenSource.Cancel(); // force timer loop end
|
_tokenSource.Cancel(); // force timer loop end
|
||||||
|
|
||||||
// if this was an arrival, create the matching departure call and open it
|
// if this was an arrival, create the matching departure call and open it
|
||||||
if (esc.ShipcallModel.Shipcall?.Type == (int)Extensions.TypeEnum.Incoming)
|
if (esc.ShipcallModel.Shipcall?.Type == ShipcallType.Arrival)
|
||||||
{
|
{
|
||||||
ShipcallControlModel scmOut = new();
|
ShipcallControlModel scmOut = new();
|
||||||
scmOut.Shipcall = new();
|
scmOut.Shipcall = new();
|
||||||
scmOut.Shipcall.Type = (int)Extensions.TypeEnum.Outgoing;
|
scmOut.Shipcall.Type = ShipcallType.Departure;
|
||||||
scmOut.Shipcall.ShipId = esc.ShipcallModel.Shipcall.ShipId;
|
scmOut.Shipcall.ShipId = esc.ShipcallModel.Shipcall.ShipId;
|
||||||
scmOut.Ship = esc.ShipcallModel.Ship;
|
scmOut.Ship = esc.ShipcallModel.Ship;
|
||||||
DateTime eta = esc.ShipcallModel.Shipcall?.Eta ?? DateTime.Now;
|
DateTime eta = esc.ShipcallModel.Shipcall?.Eta ?? DateTime.Now;
|
||||||
@ -321,7 +326,7 @@ namespace BreCalClient
|
|||||||
private async void LoadStaticLists()
|
private async void LoadStaticLists()
|
||||||
{
|
{
|
||||||
BreCalLists.InitializeBerths(await _staticApi.BerthsGetAsync());
|
BreCalLists.InitializeBerths(await _staticApi.BerthsGetAsync());
|
||||||
BreCalLists.InitializeShips(await _staticApi.ShipsGetAsync());
|
BreCalLists.InitializeShips(await _shipApi.ShipsGetAsync());
|
||||||
BreCalLists.InitializeParticipants(await _staticApi.ParticipantsGetAsync());
|
BreCalLists.InitializeParticipants(await _staticApi.ParticipantsGetAsync());
|
||||||
|
|
||||||
this.searchFilterControl.SetBerths(BreCalLists.Berths);
|
this.searchFilterControl.SetBerths(BreCalLists.Berths);
|
||||||
@ -535,8 +540,8 @@ namespace BreCalClient
|
|||||||
|
|
||||||
if(sfm.Berths.Count > 0 )
|
if(sfm.Berths.Count > 0 )
|
||||||
{
|
{
|
||||||
this._visibleControlModels.RemoveAll(x => (!sfm.Berths.Contains((x.Shipcall?.ArrivalBerthId) ?? -1) && (x.Shipcall?.Type == (int) Extensions.TypeEnum.Incoming)) ||
|
this._visibleControlModels.RemoveAll(x => (!sfm.Berths.Contains((x.Shipcall?.ArrivalBerthId) ?? -1) && (x.Shipcall?.Type == ShipcallType.Arrival)) ||
|
||||||
(!sfm.Berths.Contains((x.Shipcall?.DepartureBerthId) ?? -1) && (x.Shipcall?.Type != (int) Extensions.TypeEnum.Incoming)));
|
(!sfm.Berths.Contains((x.Shipcall?.DepartureBerthId) ?? -1) && (x.Shipcall?.Type != ShipcallType.Arrival)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sfm.Agencies.Count > 0 )
|
if(sfm.Agencies.Count > 0 )
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user