fixing project issues

refactor
Don Oerkfitz 12 months ago
parent c2a47bd539
commit e6b5eaf851

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using OSI.API.Business.Objects;
namespace OSI.API.DAL.Base
{

@ -88,21 +88,6 @@ namespace OSI.API.DAL.Base
if (!DBReader.IsDBNull(columnID))
{
// const int CHUNK_SIZE = 2 * 1024;
// byte[] buffer = new byte[CHUNK_SIZE];
// long bytesRead;
// long fieldOffset = 0;
// using (var stream = new MemoryStream())
// {
// while ((bytesRead = DBReader.GetBytes(columnID, fieldOffset, buffer, 0, buffer.Length)) == buffer.Length)
// {
// stream.Write(buffer, 0, (int)bytesRead);
// fieldOffset += bytesRead;
// }
// rv = stream.ToArray();
// }
rv = (byte[])DBReader[columnID];
}

@ -0,0 +1,81 @@
namespace OSI.API.DAL.Common
{
public class AddressObject
{
public string? Name { get; set; }
public string? AddressLine1 { get; set; }
public string? AddressLine2 { get; set; }
public string? AddressLine3 { get; set; }
public string? City { get; set; }
public string? State { get; set; }
public string? Zip { get; set; }
public string CSZ { get => $"{City}, {StateNameFromAbbreviation(State)} {Zip}"; }
private string StateNameFromAbbreviation(string abbr)
{
string rv = abbr;
Dictionary<string, string> states = new Dictionary<string, string>()
{
{"AL", "Alabama"},
{"AK", "Alaska"},
{"AZ", "Arizona"},
{"AR", "Arkansas"},
{"CA", "California"},
{"CO", "Colorado"},
{"CT", "Connecticut"},
{"DE", "Delaware"},
{"DC", "District of Columbia"},
{"FL", "Florida"},
{"GA", "Georgia"},
{"HI", "Hawaii"},
{"ID", "Idaho"},
{"IL", "Illinois"},
{"IN", "Indiana"},
{"IA", "Iowa"},
{"KS", "Kansas"},
{"KY", "Kentucky"},
{"LA", "Louisiana"},
{"ME", "Maine"},
{"MD", "Maryland"},
{"MA", "Massachusetts"},
{"MI", "Michigan"},
{"MN", "Minnesota"},
{"MS", "Mississippi"},
{"MO", "Missouri"},
{"MT", "Montana"},
{"NE", "Nebraska"},
{"NV", "Nevada"},
{"NH", "New Hampshire"},
{"NJ", "New Jersey"},
{"NM", "New Mexico"},
{"NY", "New York"},
{"NC", "North Carolina"},
{"ND", "North Dakota"},
{"OH", "Ohio"},
{"OK", "Oklahoma"},
{"OR", "Oregon"},
{"PA", "Pennsylvania"},
{"RI", "Rhode Island"},
{"SC", "South Carolina"},
{"SD", "South Dakota"},
{"TN", "Tennessee"},
{"TX", "Texas"},
{"UT", "Utah"},
{"VT", "Vermont"},
{"VA", "Virginia"},
{"WA", "Washington"},
{"WV", "West Virginia"},
{"WI", "Wisconsin"},
{"WY", "Wyoming"}
};
if (states.ContainsKey(abbr))
rv = states[abbr];
return rv;
}
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using OSI.API.DAL.Base;
namespace OSI.API.DAL.Invoice
{

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System;
using OSI.API.DAL.Client;
namespace OSI.API.DAL.Invoice
{
@ -9,17 +10,17 @@ namespace OSI.API.DAL.Invoice
public float InvoiceAmount { get; set; }
public float Discount { get; set; }
public float Tax { get; set; }
public List<InvoiceObjectLineItems> InvoiceLineItems { get; set; }
public Notes Notes { get; set; }
public List<InvoiceObjectLineItems>? InvoiceLineItems { get; set; }
public Notes? Notes { get; set; }
public DateTime InvoiceDate { get; set; }
public DateTime DueDate { get; set; }
public ClientObject Client { get; set; }
public ClientObject? Client { get; set; }
}
public class InvoiceObjectLineItems
{
public string Item { get; set; }
public string Description { get; set; }
public string? Item { get; set; }
public string? Description { get; set; }
public float Cost { get; set; }
public float Quantity { get; set; }
public float Tax { get; set; }
@ -30,9 +31,9 @@ namespace OSI.API.DAL.Invoice
public class Notes
{
public string PublicNotes { get; set; }
public string PrivateNotes { get; set; }
public string Terms { get; set; }
public string? PublicNotes { get; set; }
public string? PrivateNotes { get; set; }
public string? Terms { get; set; }
}
}

@ -4,8 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OSI.API.Business.Objects;
using OSI.API.Business.DAO;
using OSI.API.DAL.Invoice;
namespace OSI.API.Controllers
{
@ -21,13 +20,13 @@ namespace OSI.API.Controllers
public override IActionResult Get()
{
//> get all invoices as a list of InvoiceObjects
using InvoiceDAO dao = new(new Common.Library.SQL.Base.SQLBase.DBConnectionInformation());
using InvoiceDAO dao = new(new OSI.API.DAL.Base.SQLBase.DBConnectionInformation());
return new JsonResult(dao.GetAll());
}
public override IActionResult Get(int id)
{
using InvoiceDAO dao = new(new Common.Library.SQL.Base.SQLBase.DBConnectionInformation());
using InvoiceDAO dao = new(new OSI.API.DAL.Base.SQLBase.DBConnectionInformation());
return new JsonResult(dao.Get(id));
}

@ -10,7 +10,7 @@
<PackageReference Include="dbup-mysql" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
<PackageReference Include="Mysql.Data" Version="8.0.25" />
<PackageReference Include="Mysql.Data" Version="8.0.33" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>

Loading…
Cancel
Save