private async void CancelSaveControl(object obj) { await Dbcontext.CloseAsync(); await Application.Current.MainPage.Navigation.PopAsync(); }
public async void GetControlRows() { try { InternalControlPerformRow cont; ICErrorCodeCls codeCls; ICErrorCodeGroupCls codeGroupCls; ICErrorCodeMainGroupCls maingroupCls; PhotoCls photoCls; var result = Dbcontext.GetOfficeInternalControlLog(Application.Current.Properties["UN"].ToString(), Application.Current.Properties["PW"].ToString(), Application.Current.Properties["Ucid"].ToString(), IniControlLogId); ObservableCollection <InternalControlPerformRow> temp = new ObservableCollection <InternalControlPerformRow>(); if (result != null) { PerformedDate = result.Created; if (result.Employee != null) { SelectedEmployee = AllOffices.SelectMany(emp => emp.Employees).Where(em => em.Id == result.Employee.Id).FirstOrDefault(); } if (result.IsPartSaved == true) { IsEditable = true; IsVisible = true; } else { IsEditable = false; IsVisible = false; } if (result.InternalControlOffice.HasVehicleBrand == true) { VehicleIsVisible = true; AONr = result.AoNr; RegNr = result.RegNr; if (result.VehicleBrand != null) { SelectedVehicleBrand = AllVehicleBrands.Where(vb => vb.Id == result.VehicleBrand.Id).FirstOrDefault(); } } if (result.Rows != null && result.Rows.Length > 0) { foreach (var data in result.Rows) { cont = new InternalControlPerformRow(); if (data.Id != null) { cont.Id = (int)data.Id; } cont.Question = data.Text; cont.TextColor = Xamarin.Forms.Color.Gray; cont.IndicatorColor = Xamarin.Forms.Color.Gray; cont.Group = data.Group; cont.Helptext = data.HelpText; cont.IsEA = data.IsEA; cont.IsNotOk = data.IsNo; cont.IsOk = data.IsYes; cont.ErrorCodeMainGroups = ErrorCodeMainGroups; cont.Comment = data.Comment; if (result.IsPartSaved == true) { cont.AddErrorCodesIsVisible = true; cont.IsClickabled = true; cont.AddPhotoIsVisible = true; } else { cont.AddErrorCodesIsVisible = false; cont.IsClickabled = false; cont.AddPhotoIsVisible = false; } if (data.ErrorCodes != null && data.ErrorCodes.Count() > 0) { foreach (ServiceReference1.ICErrorCodeData codedata in data.ErrorCodes) { codeCls = new ICErrorCodeCls(); codeCls.Code = codedata.Code; codeCls.Id = codedata.Id; if (codedata.Group != null) { codeGroupCls = new ICErrorCodeGroupCls(); codeGroupCls.Id = codedata.Group.Id; codeGroupCls.Name = codedata.Group.Name; codeCls.Group = codeGroupCls; if (codedata.Group.MainGroup != null) { maingroupCls = new ICErrorCodeMainGroupCls(); maingroupCls.Id = codedata.Group.MainGroup.Id; maingroupCls.Name = codedata.Group.MainGroup.Name; codeCls.Group.MainGroup = maingroupCls; } } cont.SelectedErrorCodes.Add(codeCls); } } cont.DeleteErrorCodesIsVisible = false; cont.DeletePhotoIsVisible = false; cont.AddedPhotos = new ObservableCollection <Classes.Photo.PhotoCls>(); if (data.ImageFiles != null && data.ImageFiles.Count() > 0) { foreach (ServiceReference1.ICOLogRowFileData file in data.ImageFiles) { photoCls = new PhotoCls(); photoCls.Name = file.FileName; photoCls.Path = file.FilePath; photoCls.Id = file.Id; cont.AddedPhotos.Add(photoCls); } } temp.Add(cont); } } } AllRows = new ObservableCollection <InternalControlPerformRow>(temp); // await Dbcontext.CloseAsync(); } catch (Exception e) { await Dbcontext.CloseAsync(); await Application.Current.MainPage.DisplayAlert("Fel", e.Message, "Stäng"); } //Dbcontext = new ServiceReference1.Service1Client(ServiceReference1.Service1Client.EndpointConfiguration.BasicHttpBinding_IService1); }