Witam serdecznie. Przy pobieraniu danych z API otrzymuję wyjątek:
the added or subtracted value results in an un-representable datetime
Oto model w mojej aplikacji:
public class WorkTimeModel
{
public Guid Id { get; set; }
[JsonProperty("ApplicationUser")]
public ApplicationUser User { get; set; }
public DateTime StartTime { get; set; }
public DateTime? EndTime { get; set; }
public ePlaceType PlaceType { get; set; }
[JsonProperty("PlaceCar")]
public Place_CarModel Car { get; set; }
[JsonProperty("PlaceOffice")]
public Place_OfficeModel Office { get; set; }
public double GetWorkTimeProgressProcentage(TimeSpan WorkTime)
{
DateTime maxWorkDate = StartTime.AddTicks(WorkTime.Ticks).AddTicks(-StartTime.Ticks);
DateTime now = DateTime.Now.AddTicks(-StartTime.Ticks);
return (now.Ticks * 100) / maxWorkDate.Ticks;
}
}
A tutaj zwrotka z mojego API:
{
"Success": true,
"Error": "",
"Data": {
"Id": "ed34302e-efef-454c-9afa-5e1d93863bfb",
"ApplicationUserId": "782wcea0-29bc-4167-a820-7d7cbe010154",
"ApplicationUser": {
"Id": "782wcea0-29bc-4167-a820-7d7cbe010154",
"Login": "login",
"Password": "haslo",
"FirstName": "Jan",
"LastName": "Kowalski",
"Roles": "{\"Values\":[\"Technician\",\"Officeman\",\"Warehouseman\"]}",
"Token": "56w6a2f4-862d-4d27-a673-610g8301cfba",
"IsDeleted": false
},
"StartTime": "2021-11-08T12:36:55.6649463",
"EndTime": null,
"PlaceType": 0,
"PlaceCarId": "70686183-1659-4fb2-9775-052e6bc59429",
"PlaceCar": {
"Id": "70686183-1659-4fb2-9775-052e6bc59429",
"PlaceName": "Opel Astra",
"RegistrationNumber": "GDA LD908",
"QrCode": "car1"
},
"PlaceOfficeId": null,
"PlaceOffice": null
}
}
Co może być nie tak?