mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-20 06:57:15 +00:00
Added invoice export function and started implementation of unitofwork pattern (#43)
* complete read invoices from db * wip * wip * wip * wip * wip * wip * wip * wip * updated nuget package spapi * WIP * wip, now test * wip, jut need to fix tax inclusive line amounts not supported * wip * wip, before I f everything up * no, it complies now, this is the one before I f everything up * wip * wip * wip, logic ready for testing * wip it builds!!!! * wip tested, working, need to complete the gui section * wip * wip * wip - created export invoice data delete, time for testing * wip testing phase * wip - delete function fully tested and working * wip on to sorting out the issue with settlement invoices not tallying * wip * wip * wip * wip * wip before I complete change the ReadInvoiceLineItem sections * that appears to have worked, on with the main quest * no it's doesn't work, saving before i remove the confusing cache system (just use a dictionary!!) * wipping picadilli * wip * wip * implemented uow on inovice export, now for testing * wip * wip all tested do invoice currency convertion fearure * wip * pretty much done so long as xero accepts the exported invoices * Complete!
This commit is contained in:
@@ -5,6 +5,7 @@ using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database
|
||||
{
|
||||
@@ -12,9 +13,12 @@ namespace bnhtrade.Core.Data.Database
|
||||
/// Step 1: Call the methods for each where clause you want to create. This can be done multiple times to create an sql where string. Pay attention
|
||||
/// to the prefixes that you'll require between each where clause, as each time a method is called the sql statement will be appended to the previous sql
|
||||
/// string.
|
||||
///
|
||||
/// Step 2: Appened the created sql string to your sql statement, NB the WHERE statemet is not included by default.
|
||||
///
|
||||
/// Step 3: Once you've created your sql command object, add the parameters to it using the method contained within this class.
|
||||
/// STep 4: exceute your sql commend.
|
||||
///
|
||||
/// Step 4: exceute your sql commend.
|
||||
/// </summary>
|
||||
public class SqlWhereBuilder
|
||||
{
|
||||
@@ -44,6 +48,21 @@ namespace bnhtrade.Core.Data.Database
|
||||
|
||||
public Dictionary<string, object> ParameterList { get; private set; }
|
||||
|
||||
public int ParameterListCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ParameterList == null || ParameterList.Any() == false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ParameterList.Count();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the class
|
||||
/// </summary>
|
||||
@@ -83,7 +102,7 @@ namespace bnhtrade.Core.Data.Database
|
||||
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
|
||||
/// <param name="phraseList">List of phrases to test in condition statement</param>
|
||||
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void LikeAnd(string columnReference, List<string> phraseList, string wherePrefix = null)
|
||||
public void LikeAnd(string columnReference, IEnumerable<string> phraseList, string wherePrefix = null)
|
||||
{
|
||||
Like(columnReference, phraseList, true, wherePrefix);
|
||||
}
|
||||
@@ -94,12 +113,12 @@ namespace bnhtrade.Core.Data.Database
|
||||
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
|
||||
/// <param name="phraseList">List of phrases to test in condition statement</param>
|
||||
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void LikeOr(string columnReference, List<string> phraseList, string wherePrefix = null)
|
||||
public void LikeOr(string columnReference, IEnumerable<string> phraseList, string wherePrefix = null)
|
||||
{
|
||||
Like(columnReference, phraseList, false, wherePrefix);
|
||||
}
|
||||
|
||||
private void Like(string columnReference, List<string> phraseList, bool isAnd, string wherePrefix = null)
|
||||
private void Like(string columnReference, IEnumerable<string> phraseList, bool isAnd, string wherePrefix = null)
|
||||
{
|
||||
if (phraseList == null || !phraseList.Any())
|
||||
{
|
||||
@@ -107,7 +126,7 @@ namespace bnhtrade.Core.Data.Database
|
||||
}
|
||||
|
||||
// ensure no values are repeated
|
||||
var distinctList = phraseList.ToList();
|
||||
var distinctList = phraseList.Distinct().ToList();
|
||||
|
||||
// clean the list
|
||||
for (int i = 0; i < distinctList.Count; i++)
|
||||
@@ -166,7 +185,7 @@ namespace bnhtrade.Core.Data.Database
|
||||
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
|
||||
/// <param name="orValueList">List of values to test in condition statement</param>
|
||||
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void In(string columnReference, List<string> orValueList, string wherePrefix = null)
|
||||
public void In(string columnReference, IEnumerable<object> orValueList, string wherePrefix = null)
|
||||
{
|
||||
if (orValueList == null || !orValueList.Any())
|
||||
{
|
||||
@@ -208,19 +227,19 @@ namespace bnhtrade.Core.Data.Database
|
||||
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
|
||||
/// <param name="orValueList">List of values to test in condition statement</param>
|
||||
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void In(string columnReference, List<int> orValueList, string wherePrefix = null)
|
||||
public void In(string columnReference, IEnumerable<string> orValueList, string wherePrefix = null)
|
||||
{
|
||||
var stringList = new List<string>();
|
||||
var objectList = new List<object>();
|
||||
|
||||
if (orValueList != null || !orValueList.Any())
|
||||
if (orValueList != null && orValueList.Any())
|
||||
{
|
||||
foreach (int value in orValueList)
|
||||
foreach (string value in orValueList)
|
||||
{
|
||||
stringList.Add(value.ToString());
|
||||
objectList.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
In(columnReference, stringList, wherePrefix);
|
||||
In(columnReference, objectList, wherePrefix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -229,19 +248,55 @@ namespace bnhtrade.Core.Data.Database
|
||||
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
|
||||
/// <param name="orValueList">List of values to test in condition statement</param>
|
||||
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void In(string columnReference, List<uint> orValueList, string wherePrefix = null)
|
||||
public void In(string columnReference, IEnumerable<int> orValueList, string wherePrefix = null)
|
||||
{
|
||||
var stringList = new List<string>();
|
||||
var objectList = new List<object>();
|
||||
|
||||
if (orValueList != null || !orValueList.Any())
|
||||
if (orValueList != null && orValueList.Any())
|
||||
{
|
||||
foreach (uint value in orValueList)
|
||||
foreach (var value in orValueList)
|
||||
{
|
||||
stringList.Add(value.ToString());
|
||||
objectList.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
In(columnReference, stringList, wherePrefix);
|
||||
In(columnReference, objectList, wherePrefix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append an 'In' statement and parameter list to the class properties
|
||||
/// </summary>
|
||||
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
|
||||
/// <param name="orValueList">List of values to test in condition statement</param>
|
||||
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void In(string columnReference, IEnumerable<uint> orValueList, string wherePrefix = null)
|
||||
{
|
||||
var objectList = new List<object>();
|
||||
|
||||
if (orValueList != null && orValueList.Any())
|
||||
{
|
||||
foreach (var value in orValueList)
|
||||
{
|
||||
objectList.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
In(columnReference, objectList, wherePrefix);
|
||||
}
|
||||
|
||||
public void In(string columnReference, IEnumerable<DateTime> orValueList, string wherePrefix = null)
|
||||
{
|
||||
var objectList = new List<object>();
|
||||
|
||||
if (orValueList != null && orValueList.Any())
|
||||
{
|
||||
foreach(var value in orValueList)
|
||||
{
|
||||
objectList.Add(value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
In(columnReference, objectList, wherePrefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user