public void SetSection(ViewModels.ReturnOfPermit ret) { ReturnMinutesEntry.Text = ret.ReturnMinutes; ReturnName.Text = ret.ReturnPrintName; ReturnCompany.Text = ret.ReturnCompany; ReturnJobTitle.Text = ret.ReturnJobTitle; var date = DateTime.Parse(ret.ReturnDate.ToString()); ReturnDatePicker.Date = date; var time1 = TimeSpan.Parse(ret.ReturnTime.ToString()); ReturnTime.Time = time1; ReturnCompletedCheckbox.IsChecked = ret.ReturnCompleted; ReturnCancelledCheckbox.IsChecked = ret.ReturnCancelled; if (ret.ReturnSigned != null) { ReturnSignatureImage.Source = ImageSource.FromStream(() => new MemoryStream(ret.ReturnSigned)); ReturnSignatureImage.IsVisible = true; ReturnSignature.IsVisible = false; } else { ReturnSignature.IsVisible = true; } }
public async Task <ViewModels.ReturnOfPermit> GetSection(Models.HotWorksPermit hotWorksPermit) { var returnTime = ReturnTime.NullableTime; if (returnTime == null) { returnTime = TimeSpan.Zero; } ViewModels.ReturnOfPermit ret = new ViewModels.ReturnOfPermit { ReturnMinutes = ReturnMinutesEntry.Text, ReturnPrintName = ReturnName.Text, ReturnCompany = ReturnCompany.Text, ReturnJobTitle = ReturnJobTitle.Text, ReturnDate = ReturnDatePicker.Date, ReturnTime = returnTime, ReturnCancelled = ReturnCancelledCheckbox.IsChecked, ReturnCompleted = ReturnCompletedCheckbox.IsChecked }; if (hotWorksPermit != null) { var worksPermitObject = JsonConvert.DeserializeObject <HotWorkPermitViewModel>(hotWorksPermit.Content); if (worksPermitObject.ReturnOfPermit.ReturnSigned != null) { ret.ReturnSigned = worksPermitObject.ReturnOfPermit.ReturnSigned; } else { var image = await ReturnSignature.GetImageStreamAsync(SignatureImageFormat.Png); if (image != null) { byte[] arr; using (var ms = new MemoryStream()) { await image.CopyToAsync(ms); arr = ms.ToArray(); } ret.ReturnSigned = arr; } } } else { var image = await ReturnSignature.GetImageStreamAsync(SignatureImageFormat.Png); if (image != null) { byte[] arr; using (var ms = new MemoryStream()) { await image.CopyToAsync(ms); arr = ms.ToArray(); } ret.ReturnSigned = arr; } } return(ret); }