private async Task <ShiftDetailModel> ShowOpenCloseShiftDialog(ShiftRecordType shiftDialogType) { string okButtonText; if (shiftDialogType is ShiftRecordType.None) { throw new ArgumentException(nameof(shiftDialogType)); } if (shiftDialogType is ShiftRecordType.Open) { okButtonText = Localization.GetLocalizedString(LocalizationStrings.OpenCloseShiftOpenOk); } else { okButtonText = Localization.GetLocalizedString(LocalizationStrings.OpenCloseShiftCloseOk); } var vm = new OpenCloseShiftViewModel(_messenger, shiftDialogType); var res = await new Client.Controls.ContentDialog() { XamlRoot = _xamlRoot, Content = new OpenCloseShift() { DataContext = vm }, PrimaryButtonText = okButtonText, CloseButtonText = Localization.GetLocalizedString(LocalizationStrings.CancelButton), DefaultButton = ContentDialogButton.Primary }.ShowAsync(); return(res is ContentDialogResult.Primary ? vm.Data : null); }
private async Task <bool> AddShiftRecord(ShiftRecordType shiftRecordType) { var shiftData = await ShowOpenCloseShiftDialog(shiftRecordType); if (shiftData is not null) { _vmLocator._dbShift.AddShift(shiftData); return(true); } return(false); }