private async Task ExecuteOnUnvailibility() { if (!Contact.potential.Exists(i => i.network == Token.network) & !DataStore.GetEditContactsToUpload().ToList().Exists(i => i.Contact_Id == Contact._id)) { if (await DependencyService.Get <IDialog>().AlertAsync("", "Le Contact n'a pas de potentiel , Vouler vous le modifier ?", "Oui", "Non")) { var lazem_nelgalha_hal = new ContactPage_ViewModel(Navigation); await Navigation.PushModalAsync(new EditContact_View(Token, lazem_nelgalha_hal.Wilaya, lazem_nelgalha_hal.All_Commune, lazem_nelgalha_hal.Speciality, Contact)); } } else { if (await DependencyService.Get <IDialog>().AlertAsync("", "Voulez Vous Ajouter le rapport ?", "Oui", "Non")) { var compareLocation = new CompareLocation(); var Result = compareLocation.CompareLocationFunction(DataStore, Contact); string json; if (IsFreeMission) { var Respone_Free = new Free_Unvailability(); Respone_Free.client = Contact._id; Respone_Free.duration = Result.Item2; if (Result.Item1) { Respone_Free.coords.Add(Result.Item3.lat); Respone_Free.coords.Add(Result.Item3.lng); } Respone_Free.unavailability_reason = "Indisponible"; Respone_Free.valid = Result.Item1; Respone_Free.visited = true; Respone_Free.visit_time = Result.Item4; json = JsonConvert.SerializeObject(Respone_Free, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); } else { var Respone = new Unvailability(); if (Result.Item1) { Respone.coords.Add(Result.Item3.lat); Respone.coords.Add(Result.Item3.lng); } Respone.duration = Result.Item2; Respone.unavailability_reason = "Indisponible"; Respone.valid = Result.Item1; Respone.visited = true; Respone.visit_time = Result.Item4; json = JsonConvert.SerializeObject(Respone, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); } var data = new UnvailibilityToUpload_Model { Client_name = Contact.lastname + " " + Contact.firstname, Contact_id = Contact._id, Date = DateTime.Now, Global_id = Global_Id, IsFreeMission = IsFreeMission, Json = json, Mission_id = Mission_Id }; DataStore.AddUnvailibilityToUpload(data); MessagingCenter.Send(this, "UploadContactsTableModified"); await Navigation.PopModalAsync(); } } }
private List <KeyValuePair <string, string> > SerializeVisiteJson() { IsBusy = true; if (!CheckRequiredData()) { DependencyService.Get <IMessage>().ShortAlert("Vous devez remplir les champs obligatoires !"); IsBusy = false; return(null); } var Material_delivred = QuantityDelivredValidation(); if (!Material_delivred.Item1) { DependencyService.Get <IMessage>().ShortAlert("Erreur Materiél Remis !"); IsBusy = false; return(null); } var compareLocation = new CompareLocation(); var Result = compareLocation.CompareLocationFunction(DataStore, Contact); if (Result.Item1) { Responce.mission.coords.Add(Result.Item3.lat); Responce.mission.coords.Add(Result.Item3.lng); } Responce.mission.valid = Result.Item1; Responce.mission.visited = true; Responce.mission.visit_end_time = Result.Item5; Responce.mission.visit_time = Result.Item4; Responce.mission.dual = (Selected_Supervisor == null) ? false : true; Responce.repport.gps_duration = Result.Item2; Responce.repport.products_presented.AddRange(productsPresentedSerialize()); Responce.repport.material_delivered.AddRange(Material_delivred.Item2); Responce.repport.agent_note = Agent_Note; Responce.repport.authority = Selected_Authority; Responce.repport.category = Selected_Categorie; Responce.repport.client_note = VisitedPerson_Note; Responce.repport.dual_with = (Selected_Supervisor == null) ? null : Selected_Supervisor._id; Responce.repport.duration = Selected_Duration; Responce.repport.receptivity = Selected_Receptivity; Responce.repport.visit_quality = Selected_Quality; Responce.repport.waiting_time = Selected_Wait_Time; List <Product> Products_sales = new List <Product>(); Responce.order.products.AddRange(Products_sales); Responce.order.total = 0; List <MissionAnswer> missionAnswer = new List <MissionAnswer>(); Responce.repport.mission_answers.AddRange(missionAnswer); var mission_json = JsonConvert.SerializeObject(Responce.mission, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var repport_json = JsonConvert.SerializeObject(Responce.repport, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var order_json = JsonConvert.SerializeObject(Responce.order, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var values = new List <KeyValuePair <string, string> >(); values.Add(new KeyValuePair <string, string>("mission", mission_json)); values.Add(new KeyValuePair <string, string>("repport", repport_json)); values.Add(new KeyValuePair <string, string>("order", order_json)); IsBusy = false; return(values); }