devrait fixer la validation du devis
This commit is contained in:
parent
c3e2a998c3
commit
b5ccc44c12
2 changed files with 19 additions and 16 deletions
|
|
@ -10,6 +10,7 @@ namespace ZicMoove.Data
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class EstimateEntity : RemoteEntity<Estimate, long>
|
public class EstimateEntity : RemoteEntity<Estimate, long>
|
||||||
{
|
{
|
||||||
|
|
@ -17,18 +18,15 @@ namespace ZicMoove.Data
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void SignAsProvider(Estimate estimate, Stream stream)
|
public async Task SignAsProvider(Estimate estimate, Stream stream)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (estimate.Id == 0)
|
if (estimate.Id == 0)
|
||||||
{
|
{
|
||||||
var ok = await this.Create(estimate);
|
if (!await this.Create(estimate))
|
||||||
if (!ok)
|
|
||||||
{
|
{
|
||||||
await App.DisplayAlert("Erreur d'accès au serveur", "Echec de l'envoi de l'estimation");
|
await App.DisplayAlert("Erreur d'accès au serveur", "Echec de l'envoi de l'estimation");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
this.Add(estimate);
|
|
||||||
}
|
}
|
||||||
using (HttpClient client = UserHelpers.CreateJsonClient())
|
using (HttpClient client = UserHelpers.CreateJsonClient())
|
||||||
{
|
{
|
||||||
|
|
@ -40,24 +38,29 @@ namespace ZicMoove.Data
|
||||||
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
|
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
|
||||||
content.Headers.Add("Content-Disposition", $"form-data; name=\"file\"; filename=\"{filename}\"");
|
content.Headers.Add("Content-Disposition", $"form-data; name=\"file\"; filename=\"{filename}\"");
|
||||||
requestContent.Add(content, "file", filename);
|
requestContent.Add(content, "file", filename);
|
||||||
|
|
||||||
using (var response = await client.PostAsync(
|
using (var response = await client.PostAsync(
|
||||||
Constants.YavscApiUrl + $"/pdfestimate/prosign/{estimate.Id}", requestContent))
|
Constants.YavscApiUrl + $"/pdfestimate/prosign/{estimate.Id}", requestContent))
|
||||||
{
|
{
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
var errContent = await response.Content.ReadAsStringAsync();
|
var errContent = await response.Content.ReadAsStringAsync();
|
||||||
throw new ApiCallFailedException($"SignAsProvider: {response.StatusCode} / {errContent}");
|
await App.DisplayAlert("SignAsProvider", $"{response.StatusCode}: {errContent}");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
var json = await response.Content.ReadAsStringAsync();
|
var json = await response.Content.ReadAsStringAsync();
|
||||||
JsonConvert.PopulateObject(json, estimate);
|
JsonConvert.PopulateObject(json, estimate);
|
||||||
|
this.Add(estimate);
|
||||||
|
this.SaveEntity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(ex.ToString());
|
await App.DisplayAlert("SignAsProvider", ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.SaveEntity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Check we don't loose nothing here
|
// TODO Check we don't loose nothing here
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ namespace ZicMoove.Pages.EstimatePages
|
||||||
*/
|
*/
|
||||||
|
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
DataManager.Instance.Estimates.SignAsProvider(estimate, stream);
|
await DataManager.Instance.Estimates.SignAsProvider(estimate, stream);
|
||||||
DataManager.Instance.Estimates.SaveEntity();
|
DataManager.Instance.Estimates.SaveEntity();
|
||||||
}
|
}
|
||||||
IsBusy = false;
|
IsBusy = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue