/** * If the user press the stop icon this method is called to safe a summery to the database */ public async Task InspectionStopedAsync() { try { Stop = DateTime.Now; var TotalInspected = DevicesInspected.Count(); var TotalApproved = DevicesOk.Count(); var TotalDisApproved = DevicesNotOk.Count(); var remark = await UserDialogs.Instance.PromptAsync("", "", "stoppen", null, "reden van afsluiten"); sLogger.ControlRoundHasStopped(remark.Text); if (remark.Ok) { var inspectionSummary = new InspectionSummaryRepresentationForCreation(); inspectionSummary.OperatorId = UserService.Operator.UserId; inspectionSummary.BackupOperatorId = UserService.BackupOperator?.UserId; inspectionSummary.OrganisationUnitId = OrganisationUnitId; inspectionSummary.LocationId = LocationId; inspectionSummary.DateStarted = Start; inspectionSummary.DateFinished = Stop; inspectionSummary.Completed = false; inspectionSummary.TotalToInspect = DevicesInspected.Count + DevicesToInspect.Count; inspectionSummary.TotalInspected = DevicesInspected.Count; inspectionSummary.TotalApproved = DevicesOk.Count; inspectionSummary.TotalDisApproved = DevicesNotOk.Count; inspectionSummary.Remarks = remark.Text; var config = new MapperConfiguration(cfg => { cfg.CreateMap <EquipmentReportItemModel, EquipmentReportItemRepresentation>(); }); mapper = config.CreateMapper(); inspectionSummary.ReportItems = mapper.Map <List <EquipmentReportItemRepresentation> >(ReportItems); inspectionSummary.PLG_Mail = UserService.Operator.PLG_Mail; var response = await Client.PostEnsureAsync("fire-safety/inspectionsummary", inspectionSummary); DependencyService.Get <IApplicationService>().CloseApplication(); } }catch (Exception e) { sLogger.SendStopSummeryFailed(e); } }