fixed some cut and paste error and a crash when changing the assignment fails by API
This commit is contained in:
parent
282a860c42
commit
e7a6aa6584
@ -105,7 +105,7 @@ namespace BreCalClient
|
||||
|
||||
if(this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now)
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETDInThePast;
|
||||
message = BreCalClient.Resources.Resources.textETAInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ namespace BreCalClient
|
||||
|
||||
if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETAInThePast;
|
||||
message = BreCalClient.Resources.Resources.textETDInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ namespace BreCalClient
|
||||
|
||||
if (this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now)
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETDInThePast;
|
||||
message = BreCalClient.Resources.Resources.textETAInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ namespace BreCalClient
|
||||
|
||||
if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETAInThePast;
|
||||
message = BreCalClient.Resources.Resources.textETDInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -899,7 +899,10 @@ namespace BreCalClient
|
||||
try
|
||||
{
|
||||
obj.ShipcallControlModel.Shipcall?.Participants.Clear();
|
||||
obj.ShipcallControlModel.UpdateTimesAssignments(this._timesApi);
|
||||
if(! await obj.ShipcallControlModel.UpdateTimesAssignments(this._timesApi))
|
||||
{
|
||||
ShowErrorDialog(obj.ShipcallControlModel.LastErrorMessage, "Update assignments error");
|
||||
}
|
||||
foreach(ParticipantAssignment pa in obj.ShipcallControlModel.AssignedParticipants.Values)
|
||||
obj.ShipcallControlModel.Shipcall?.Participants.Add(pa);
|
||||
await _shipcallApi.ShipcallUpdateAsync(obj.ShipcallControlModel.Shipcall);
|
||||
@ -1011,7 +1014,13 @@ namespace BreCalClient
|
||||
{
|
||||
try
|
||||
{
|
||||
sc.ShipcallControlModel?.UpdateTimesAssignments(_timesApi); // if the agent changed the assignment of the participant to another
|
||||
if (sc.ShipcallControlModel != null)
|
||||
{
|
||||
if (!await sc.ShipcallControlModel.UpdateTimesAssignments(_timesApi)) // if the agent changed the assignment of the participant to another
|
||||
{
|
||||
ShowErrorDialog(sc.ShipcallControlModel.LastErrorMessage, "Error updating times assignment");
|
||||
}
|
||||
}
|
||||
|
||||
// always try to be the agent, even if we are BSMD
|
||||
if (editControl.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
|
||||
|
||||
@ -6,6 +6,7 @@ using BreCalClient.misc.Api;
|
||||
using BreCalClient.misc.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BreCalClient
|
||||
{
|
||||
@ -38,6 +39,8 @@ namespace BreCalClient
|
||||
|
||||
public string? Berth { get; set; }
|
||||
|
||||
public string LastErrorMessage { get; private set; } = "";
|
||||
|
||||
internal Dictionary<Extensions.ParticipantType, ParticipantAssignment> AssignedParticipants { get; } = new();
|
||||
|
||||
public List<Times> Times { get; set; } = new();
|
||||
@ -247,8 +250,9 @@ namespace BreCalClient
|
||||
/// This function updates the assignments for existing times records accordingly and saves them.
|
||||
/// </summary>
|
||||
/// <param name="_api">API reference to PUT eidted times</param>
|
||||
internal async void UpdateTimesAssignments(TimesApi api)
|
||||
{
|
||||
internal async Task<bool> UpdateTimesAssignments(TimesApi api)
|
||||
{
|
||||
|
||||
foreach (Extensions.ParticipantType participantType in this.AssignedParticipants.Keys)
|
||||
{
|
||||
Times? times = this.GetTimesForParticipantType(participantType);
|
||||
@ -256,7 +260,15 @@ namespace BreCalClient
|
||||
if(times.ParticipantId != this.AssignedParticipants[participantType].ParticipantId)
|
||||
{
|
||||
times.ParticipantId = this.AssignedParticipants[participantType].ParticipantId;
|
||||
await api.TimesUpdateAsync(times);
|
||||
try
|
||||
{
|
||||
await api.TimesUpdateAsync(times);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LastErrorMessage = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,9 +295,18 @@ namespace BreCalClient
|
||||
|
||||
foreach(Times times in deleteTimes)
|
||||
{
|
||||
api.TimesDelete(times.Id);
|
||||
this.Times.Remove(times);
|
||||
try
|
||||
{
|
||||
api.TimesDelete(times.Id);
|
||||
this.Times.Remove(times);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LastErrorMessage = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Loading…
Reference in New Issue
Block a user