Exemplo n.º 1
0
        private void AdjustSelectedInvoice(AdjustInputDetails adjustInputDetails)
        {
            BaseValidator validator = new BaseValidator();

            if (!validator.AdjustInvoice(adjustInputDetails))
            {
                ShowError(validator.ClientException, AdjustLineItemError);
                return;
            }
            MessageBoxResult msgResult;

            if (userdata.IsMultipleLineItemAdjust)
            {
                msgResult = MessageBox.Show("Are you sure you want to adjust this line items?", "Adjustment Confirmation", MessageBoxButton.OKCancel);
            }
            else
            {
                msgResult = MessageBox.Show("Are you sure you want to adjust these line item?", "Adjustment Confirmation", MessageBoxButton.OKCancel);
            }

            if (msgResult == MessageBoxResult.Cancel)
            {
                EnableApplicationBar();
                return;
            }

            string postData = JsonConvert.SerializeObject(adjustInputDetails);

            try
            {
                ServiceInvoker.InvokeServiceUsingPost("api/t360/LineItem/AdjustLineItems", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs)
                {
                    ServiceResponse result = serviceEventArgs.Result;
                    if (result.Status)
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            EnableApplicationBar();
                            NavigationService.GoBack();
                        });
                    }
                    else
                    {
                        List <Error> resultError = result.ErrorDetails;
                        ShowError(new AppException(resultError), AdjustLineItemError);
                        if (resultError[0] != null && T360ErrorCodes.NotInReviewerQueue == resultError[0].Code)
                        {
                            Deployment.Current.Dispatcher.BeginInvoke(() =>
                            {
                                RedirectToInvoiceList();
                            });
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                ShowError((AppException)ex);
            }
        }