Ver Fonte

Fixing build errors

Kenric Nugteren há 1 ano atrás
pai
commit
5f963aa567

+ 26 - 24
prs.server/Forms/DatabaseLicense/LicenseRenewalForm.xaml.cs

@@ -11,7 +11,6 @@ using System.Windows.Controls;
 using System.Drawing;
 using Image = System.Windows.Controls.Image;
 using System.Diagnostics;
-using FluentResults;
 using InABox.Client.Remote.Json;
 using InABox.Configuration;
 using Microsoft.Win32;
@@ -155,8 +154,7 @@ namespace PRSServer.Forms.DatabaseLicense
 
         private void LoadData()
         {
-
-            Result<bool> result = Progress.ShowModal<bool>("Getting License", progress =>
+            var result = Progress.ShowModal<bool>("Getting License", progress =>
             {
                 try
                 {
@@ -165,7 +163,7 @@ namespace PRSServer.Forms.DatabaseLicense
                     
                     progress.Report("Checking Server");
                     if (!LicenseClient.Ping("ping"))
-                        return Result.Fail<bool>("Server Unavailable");
+                        return Result.Error("Server Unavailable");
                     
                     progress.Report("Retrieving Data");
                     RetrieveFees();
@@ -176,19 +174,21 @@ namespace PRSServer.Forms.DatabaseLicense
                     foreach (var item in LicenseItems)
                         item.Rate = LicenseUtils.GetLicenseFee(item.Type);
                     
-                    return Result.Ok<bool>(true);
+                    return Result.Ok(true);
                 }
                 catch (Exception e)
                 {
-                    return Result.Fail<bool>(e.Message);
+                    return Result.Error(e.Message);
                 }
             });
 
-            if (result.IsSuccess && result.Value)
+            if (result.Get(out var success, out var error) && success)
+            {
                 UpdateWindow();
+            }
             else
             {
-                MessageWindow.ShowMessage(String.Join("\n",result.Errors.Select(x=>x.Message)), "Error");
+                MessageWindow.ShowMessage(error ?? "Error", "Error");
                 UpdateWindow();
             }
         }
@@ -375,7 +375,7 @@ namespace PRSServer.Forms.DatabaseLicense
             if (grid.EditItems(new LicenseRegistrationDetails[] { _licenseRegistrationDetails }))
             {
                 _config.Save(_licenseRegistrationDetails);
-                Result<String> result = Result.Fail("Incomplete");
+                Result<string, string> result = Result.Error("Incomplete");
                 var renewalRequest = CreateRenewal();
                 Progress.ShowModal("Processing", progress =>
                 {
@@ -384,24 +384,26 @@ namespace PRSServer.Forms.DatabaseLicense
                         // Process the Stripe Payment
                         progress.Report("Processing Payment");
                         result = ProcessStripePayment();
-                        if (result.IsFailed)
+                        if (!result.IsOK)
                             return;
                     }
                     else
                         result = Result.Ok("no payment required");
 
                     progress.Report("Creating Renewal");
-                    result = RenewLicense(renewalRequest, result.Value);
-
-                    if (result.IsFailed)
-                        return;
-                    
-                    progress.Report("Saving License");
-                    SaveLicense(result.Value);
+                    if (result.Get(out var value, out var error))
+                    {
+                        result = RenewLicense(renewalRequest, value);
+                    }
 
+                    if(result.Get(out value, out error))
+                    {
+                        progress.Report("Saving License");
+                        SaveLicense(value);
+                    }
                 });
-                if (result.IsFailed)
-                    MessageWindow.ShowMessage(String.Join("\n",result.Errors.Select(x=>x.Message)),"Error");
+                if (!result.Get(out var value, out var error))
+                    MessageWindow.ShowMessage(error, "Error");
                 else
                 {
                     MessageWindow.ShowMessage("License Updated Successfully!","Success");
@@ -411,7 +413,7 @@ namespace PRSServer.Forms.DatabaseLicense
             
         }
         
-        private Result<String> ProcessStripePayment()
+        private Result<string, string> ProcessStripePayment()
         {
             var result = "";
             var error = "";
@@ -454,8 +456,8 @@ namespace PRSServer.Forms.DatabaseLicense
                 error = $"{ex.Message}";
             }
 
-            if (!String.IsNullOrWhiteSpace(error))
-                return Result.Fail(error);
+            if (!string.IsNullOrWhiteSpace(error))
+                return Result.Error(error);
             return Result.Ok(result);
 
         }
@@ -476,7 +478,7 @@ namespace PRSServer.Forms.DatabaseLicense
             };
         }
 
-        private Result<string> RenewLicense(LicenseRenewalRequest renewalRequest, String transactionID)
+        private Result<string, string> RenewLicense(LicenseRenewalRequest renewalRequest, String transactionID)
         {
             renewalRequest.TransactionID = transactionID;
             try
@@ -486,7 +488,7 @@ namespace PRSServer.Forms.DatabaseLicense
             }
             catch (Exception e)
             {
-                return Result.Fail(e.Message);
+                return Result.Error(e.Message);
             }
         }
         

+ 6 - 6
prs.shared/Posters/MYOB/CustomerMYOBPoster.cs

@@ -118,7 +118,7 @@ public class CustomerMYOBPoster : IMYOBPoster<Customer, CustomerMYOBPosterSettin
                 return Result.Error(new Exception($"Failed to find TaxCode in MYOB with code {settings.DefaultTaxCode}: {error.Message}", error));
             }
         }
-        return Result.Ok<Exception>();
+        return Result.Ok();
     }
 
     /// <summary>
@@ -147,29 +147,29 @@ public class CustomerMYOBPoster : IMYOBPoster<Customer, CustomerMYOBPosterSettin
             {
                 if(customer.Code.Length > 15)
                 {
-                    return Result.Error<Guid, Exception>(new Exception("Customer code is longer than 15 characters"));
+                    return Result.Error(new Exception("Customer code is longer than 15 characters"));
                 }
                 var myobCustomer = new MYOBCustomer();
                 return UpdateCustomer(data, PosterUtils.LoadPosterSettings<Customer, CustomerMYOBPosterSettings>(), customer, myobCustomer, true)
-                    .MapOk(() =>
+                    .MapOk<Result<Guid, Exception>>(() =>
                     {
                         try
                         {
                             var result = service.UpdateEx(data.CompanyFile, myobCustomer, data.CompanyFileCredentials);
                             customer.PostedReference = result.UID.ToString();
-                            return Result.Ok<Guid, Exception>(result.UID);
+                            return Result.Ok(result.UID);
                         }
                         catch (Exception e)
                         {
                             CoreUtils.LogException("", e, $"Error while posting customer {customer.ID}");
-                            return Result.Error<Guid, Exception>(e);
+                            return Result.Error(e);
                         }
                     }).Flatten();
             }
             else
             {
                 customer.PostedReference = customers.Items[0].UID.ToString();
-                return Result.Ok<Guid, Exception>(customers.Items[0].UID);
+                return Result.Ok(customers.Items[0].UID);
             }
         }).Flatten();
     }

+ 4 - 4
prs.shared/Posters/MYOB/PRSMYOBPosterUtils.cs

@@ -107,13 +107,13 @@ public static class PRSMYOBPosterUtils
         var result = service.Query(data, filter, top: 1);
         if(!result.Get(out var items, out var error))
         {
-            return Result.Error<Guid, Exception>(error);
+            return Result.Error(error);
         }
         if(items.Count == 0)
         {
-            return Result.Ok<Guid, Exception>(Guid.Empty);
+            return Result.Ok(Guid.Empty);
         }
-        return Result.Ok<Guid, Exception>(items.Items[0].UID);
+        return Result.Ok(items.Items[0].UID);
     }
 
     public static Result<Guid, Exception> GetMYOBTaxCodeUID(this MYOBConnectionData data, string code)
@@ -123,7 +123,7 @@ public static class PRSMYOBPosterUtils
     {
         if(Guid.TryParse(code.PostedReference, out var id))
         {
-            return Result.Ok<Guid, Exception>(id);
+            return Result.Ok(id);
         }
         return GetMYOBTaxCodeUID(data, code.Code);
     }