Exemplo n.º 1
0
        private T Find <T>(IRepository <T> repository) where T : Document
        {
            string registrationNumber = RegistrationNumber.ToUpper().Replace(" ", string.Empty);

            return(repository.Where(item => string.Equals(item.RegistrationNumber, registrationNumber, StringComparison.CurrentCultureIgnoreCase))
                   .OrderByDescending(item => item.InspectionDate)
                   .FirstOrDefault());
        }
Exemplo n.º 2
0
        private void OnReprint(Window window)
        {
            if (string.IsNullOrEmpty(RegistrationNumber))
            {
                return;
            }

            IsLoading = true;

            Document document = FindDocumentLocally();

            if (document != null)
            {
                Print(document);
                window.Close();
                return;
            }

            GetInstance <IConnectClient>().CallAsync(ConnectHelper.GetConnectKeys(), client =>
            {
                return(client.Service.Find(RegistrationNumber.ToUpper().Replace(" ", string.Empty), DocumentType.Tachograph | DocumentType.Undownloadability | DocumentType.LetterForDecommissioning));
            },
                                                     result =>
            {
                if (result.Data == null)
                {
                    MessageBoxHelper.ShowError(Resources.ERR_UNABLE_FIND_ANY_MATCHES, Window);
                    return;
                }

                Print((Document)result.Data);
            },
                                                     exception =>
            {
                MessageBoxHelper.ShowError(Resources.TXT_ONE_OR_MORE_ERRORS, new object[] { ExceptionPolicy.HandleException(ContainerBootstrapper.Container, exception) }, window);
            },
                                                     () =>
            {
                window.Close();
            });
        }