Example #1
0
        private async void FinishRentalButton_OnClick(object sender, RoutedEventArgs e)
        {
            var clientParam = GetClientParam();
            var product     = GetProductOfParam();

            if (product == null || string.IsNullOrEmpty(clientParam))
            {
                return;
            }
            if (product.State.Equals(StateProductEnum.Available))
            {
                this.ShowInformationMessage(_resourceManager, "RENTAL_RETURNED");
                return;
            }
            var isFinishRental = _rentalService.FinishRentalProduct(clientParam, product.Id, out var differencePrice);

            if (isFinishRental)
            {
                if (differencePrice > 0)
                {
                    var message = _resourceManager.GetResourceValue("FINISH_RENTAL_DUE_PAYMENT")
                                  ?.Replace("$", product.Id)
                                  .Replace("PRICE", Convert.ToString(differencePrice, CultureInfo.InvariantCulture));
                    this.ShowCustomInformationMessage(_resourceManager, message);
                }
                else
                {
                    var message = _resourceManager.GetResourceValue("FINISH_RENTAL_SUCCESSFUL")
                                  ?.Replace("$", product.Id);
                    this.ShowCustomInformationMessage(_resourceManager, message);
                }

                await LoadDataGrid();
            }
            else
            {
                this.ShowGenericErrorDataMessage(_resourceManager);
                WindowHelper.HandleLogError(string.Empty);
            }
        }