コード例 #1
0
        private async Task EditRenewLicenseOrderAsync()
        {
            try
            {
                await ButtonSpinner.SpinAsync(async() =>
                {
                    if (_renewLicenseOrder.EndDate < DateTime.Now)
                    {
                        ValidationErrorMessage.DisplayError(nameof(RenewLicenseOrder.EndDate), $"End Date must not be less than Start Date.");
                        return;
                    }

                    if (!_renewLicenseOrder.HardwareVaults.Where(x => x.Checked).Any())
                    {
                        ValidationErrorMessage.DisplayError(nameof(RenewLicenseOrder.HardwareVaults), $"Select at least one hardware vault.");
                        return;
                    }

                    var checkedHardwareVaults = _renewLicenseOrder.HardwareVaults.Where(x => x.Checked).ToList();
                    var maxEndDate            = checkedHardwareVaults.Select(x => x.LicenseEndDate).Max();

                    if (_renewLicenseOrder.EndDate < maxEndDate)
                    {
                        ValidationErrorMessage.DisplayError(nameof(RenewLicenseOrder.HardwareVaults), $"The selected End Date less than max end date for selected hardware vaults.");
                        return;
                    }

                    LicenseOrder.ContactEmail            = _renewLicenseOrder.ContactEmail;
                    LicenseOrder.Note                    = _renewLicenseOrder.Note;
                    LicenseOrder.ProlongExistingLicenses = true;
                    LicenseOrder.StartDate               = null;
                    LicenseOrder.EndDate                 = _renewLicenseOrder.EndDate.Date;

                    await LicenseService.EditOrderAsync(LicenseOrder, checkedHardwareVaults);
                    await SynchronizationService.UpdateLicenses(ExceptPageId);
                    await ToastService.ShowToastAsync("Order created.", ToastType.Success);
                    await ModalDialogService.CloseAsync();
                });
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
コード例 #2
0
        private async Task EditNewLicenseOrderAsync()
        {
            try
            {
                await Button.SpinAsync(async() =>
                {
                    if (_newLicenseOrder.StartDate < DateTime.Now.Date)
                    {
                        ValidationErrorMessage.DisplayError(nameof(NewLicenseOrder.StartDate), $"Start Date must be at least current date.");
                        return;
                    }

                    if (_newLicenseOrder.EndDate < _newLicenseOrder.StartDate)
                    {
                        ValidationErrorMessage.DisplayError(nameof(NewLicenseOrder.EndDate), $"End Date must not be less than Start Date.");
                        return;
                    }

                    if (!_newLicenseOrder.HardwareVaults.Where(x => x.Checked).Any())
                    {
                        ValidationErrorMessage.DisplayError(nameof(NewLicenseOrder.HardwareVaults), $"Select at least one hardware vault.");
                        return;
                    }

                    LicenseOrder.ContactEmail            = _newLicenseOrder.ContactEmail;
                    LicenseOrder.Note                    = _newLicenseOrder.Note;
                    LicenseOrder.ProlongExistingLicenses = false;
                    LicenseOrder.StartDate               = _newLicenseOrder.StartDate.Date;
                    LicenseOrder.EndDate                 = _newLicenseOrder.EndDate.Date;

                    var checkedHardwareVaults = _newLicenseOrder.HardwareVaults.Where(x => x.Checked).ToList();
                    await LicenseService.EditOrderAsync(LicenseOrder, checkedHardwareVaults);
                    await ToastService.ShowToastAsync("Order created.", ToastType.Success);
                    await ModalDialogClose();
                });
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }