Compare commits
16 Commits
Author | SHA1 | Date |
---|---|---|
Don Oerkfitz | bf60d12a9a | 2 years ago |
Don Oerkfitz | e6b5eaf851 | 2 years ago |
Don Oerkfitz | c2a47bd539 | 2 years ago |
Don Oerkfitz | b9fad50539 | 2 years ago |
Don Oerkfitz | cdedda1c37 | 2 years ago |
Don Oerkfitz | 9e62eb5c05 | 2 years ago |
Don Oerkfitz | 1484b98d98 | 2 years ago |
Don Oerkfitz | 082745ac25 | 3 years ago |
Don Oerkfitz | fab692c15e | 4 years ago |
Don Oerkfitz | 8c280213e9 | 4 years ago |
Don Oerkfitz | db3c94b36e | 4 years ago |
Don Oerkfitz | 1991739287 | 4 years ago |
Don Oerkfitz | a5d4d5413f | 4 years ago |
Don Oerkfitz | 3591793d3f | 4 years ago |
Don Oerkfitz | abfbe266cf | 4 years ago |
Don Oerkfitz | cd1f420445 | 4 years ago |
@ -0,0 +1,37 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||
// Use hover for the description of the existing attributes
|
||||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||
"name": ".NET Core Launch (web)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/OSI-API/bin/Debug/net6.0/OSI-API.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/OSI-API",
|
||||
"stopAtEntry": false,
|
||||
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
|
||||
"serverReadyAction": {
|
||||
"action": "openExternally",
|
||||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceFolder}/Views"
|
||||
},
|
||||
"enableStepFiltering": false
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/OSI-API/OSI-API.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "publish",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"publish",
|
||||
"${workspaceFolder}/OSI-API/OSI-API.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "watch",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"watch",
|
||||
"run",
|
||||
"${workspaceFolder}/OSI-API/OSI-API.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace OSI.API.DAL.Base
|
||||
{
|
||||
|
||||
public abstract class DAOBase<T> : MySQL
|
||||
{
|
||||
protected DAOBase(DBConnectionInformation connectionInformation) : base(connectionInformation)
|
||||
{
|
||||
}
|
||||
|
||||
protected DAOBase(string server, string database, string username, string password) : base(server, database, username, password)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract List<T> GetAll();
|
||||
public abstract T Get(int id);
|
||||
public abstract void Create(T itemToCreate);
|
||||
public abstract void Update(T itemToUpdate);
|
||||
public abstract void Delete(int id);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace OSI.API.DAL.Base
|
||||
{
|
||||
public abstract class SQLBase : IDisposable
|
||||
{
|
||||
protected DBConnectionInformation DBConnectionInfo;
|
||||
|
||||
public enum DBType
|
||||
{
|
||||
MSSQL,
|
||||
MYSQL
|
||||
}
|
||||
public struct DBConnectionInformation
|
||||
{
|
||||
public string DBHost {get;set;}
|
||||
public string DBName {get;set;}
|
||||
public string DBUserName {get;set;}
|
||||
public string DBPassword {get;set;}
|
||||
public DBType DBType {get;set;}
|
||||
|
||||
public string GetConnectionString()
|
||||
{
|
||||
string rv = string.Empty;
|
||||
|
||||
switch(DBType)
|
||||
{
|
||||
case DBType.MSSQL:
|
||||
break;
|
||||
case DBType.MYSQL:
|
||||
rv = string.Format("Server={0};Database={1};Uid={2};Pwd={3}", DBHost, DBName, DBUserName, DBPassword);
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// free managed resources
|
||||
}
|
||||
// free native resources if there are any.
|
||||
}
|
||||
|
||||
protected string FormatNewLineForHTML(string input)
|
||||
{
|
||||
return input.Replace("\\r\\n", "<br/>");
|
||||
}
|
||||
|
||||
protected string FormatNewLineForHTML(string input, int numberOfBreaksToAdd)
|
||||
{
|
||||
StringBuilder breaks = new();
|
||||
for (int x = 0; x < numberOfBreaksToAdd; x++)
|
||||
{
|
||||
breaks.Append("<br/>");
|
||||
}
|
||||
|
||||
return input.Replace("\\r\\n", breaks.ToString());
|
||||
}
|
||||
|
||||
protected string FormatBoldForHTML(string input)
|
||||
{
|
||||
return input.Replace("[b]", "<strong>").Replace("[/b]", "</strong>");
|
||||
}
|
||||
|
||||
protected abstract void InitConnection();
|
||||
protected abstract void DisposeConnection();
|
||||
|
||||
protected abstract int GetOrdinal(string columnName);
|
||||
protected abstract int? GetInt(int columnID);
|
||||
protected abstract int? GetInt(string columnName);
|
||||
protected abstract byte? GetByte(int columnID);
|
||||
protected abstract byte? GetByte(string columnName);
|
||||
protected abstract byte[] GetBytes(int columnID);
|
||||
protected abstract byte[] GetBytes(string columnName);
|
||||
protected abstract decimal? GetDecimal(int columnID);
|
||||
protected abstract decimal? GetDecimal(string columnName);
|
||||
protected abstract long? GetLong(int columnID);
|
||||
protected abstract long? GetLong(string columnName);
|
||||
protected abstract short? GetShort(int columnID);
|
||||
protected abstract short? GetShort(string columnName);
|
||||
protected abstract string GetString(int columnID);
|
||||
protected abstract string GetString(string columnName);
|
||||
protected abstract bool? GetBool(int columnID);
|
||||
protected abstract bool? GetBool(string columnName);
|
||||
protected abstract DateTime? GetDateTime(int columnID);
|
||||
protected abstract DateTime? GetDateTime(string columnName);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using OSI.API.DAL.Common;
|
||||
|
||||
namespace OSI.API.DAL.Client
|
||||
{
|
||||
public class ClientObject
|
||||
{
|
||||
public int ClientID { get; set; }
|
||||
public string? ClientName { get; set; }
|
||||
|
||||
public AddressObject? ClientAddress { get; set; }
|
||||
}
|
||||
}
|
@ -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 ((abbr != null) && states.ContainsKey(abbr))
|
||||
rv = states[abbr];
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OSI.API.DAL.Base;
|
||||
|
||||
namespace OSI.API.DAL.Invoice
|
||||
{
|
||||
|
||||
public class InvoiceDAO : DAOBase<InvoiceObject>
|
||||
{
|
||||
public InvoiceDAO(DBConnectionInformation connectionInformation) : base(connectionInformation)
|
||||
{
|
||||
}
|
||||
|
||||
public InvoiceDAO(string server, string database, string username, string password) : base(server, database, username, password)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Create(InvoiceObject itemToCreate)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Delete(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override InvoiceObject Get(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override List<InvoiceObject> GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Update(InvoiceObject itemToUpdate)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using OSI.API.DAL.Client;
|
||||
|
||||
namespace OSI.API.DAL.Invoice
|
||||
{
|
||||
public class InvoiceObject
|
||||
{
|
||||
public int InvoiceNumber { get; set; }
|
||||
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 DateTime InvoiceDate { get; set; }
|
||||
public DateTime DueDate { get; set; }
|
||||
public ClientObject? Client { get; set; }
|
||||
}
|
||||
|
||||
public class InvoiceObjectLineItems
|
||||
{
|
||||
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; }
|
||||
//public float Total => ((Cost * Quantity) + ((Cost * Quantity) * (Tax / 100)));
|
||||
public float Total { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class Notes
|
||||
{
|
||||
public string? PublicNotes { get; set; }
|
||||
public string? PrivateNotes { get; set; }
|
||||
public string? Terms { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>OSI_API.DAL</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mysql.Data" Version="8.0.33" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>OSI_API.Test</RootNamespace>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="1.3.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OSI-API\OSI-API.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace OSI_API.Test
|
||||
{
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
namespace OSI.API.Business.Database.Installer
|
||||
{
|
||||
public class DBScriptInstaller
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OSI.API.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiController]
|
||||
public class ClientsController : ControllerBase
|
||||
{
|
||||
// GET: api/Clients
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
// GET: api/Clients/5
|
||||
[HttpGet("{id}")]
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
}
|
||||
|
||||
// POST: api/Clients
|
||||
[HttpPost]
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT: api/Clients/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE: api/Clients/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OSI.API.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiController]
|
||||
public class ExpensesController : ControllerBase
|
||||
{
|
||||
// GET: api/Expenses
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
// GET: api/Expenses/5
|
||||
[HttpGet("{id}")]
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
}
|
||||
|
||||
// POST: api/Expenses
|
||||
[HttpPost]
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT: api/Expenses/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE: api/Expenses/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OSI.API.DAL.Invoice;
|
||||
|
||||
namespace OSI.API.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiController]
|
||||
public class InvoicesController : EndpointBase<InvoiceObject>
|
||||
{
|
||||
public override IActionResult Delete(int id)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
public override IActionResult Get()
|
||||
{
|
||||
//> get all invoices as a list of InvoiceObjects
|
||||
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 OSI.API.DAL.Base.SQLBase.DBConnectionInformation());
|
||||
return new JsonResult(dao.Get(id));
|
||||
}
|
||||
|
||||
public override IActionResult Create([FromBody] InvoiceObject input)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override IActionResult Update([FromBody] InvoiceObject input)
|
||||
{
|
||||
return CreatedAtAction(
|
||||
"Get",
|
||||
routeValues: new { id = input.InvoiceNumber },
|
||||
value: input
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OSI.API.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiController]
|
||||
public class POsController : ControllerBase
|
||||
{
|
||||
// GET: api/POs
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
// GET: api/POs/5
|
||||
[HttpGet("{id}")]
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
}
|
||||
|
||||
// POST: api/POs
|
||||
[HttpPost]
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT: api/POs/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE: api/POs/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OSI.API.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiController]
|
||||
public class PaymentsController : ControllerBase
|
||||
{
|
||||
// GET: api/Payments
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
// GET: api/Payments/5
|
||||
[HttpGet("{id}")]
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
}
|
||||
|
||||
// POST: api/Payments
|
||||
[HttpPost]
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT: api/Payments/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE: api/Payments/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OSI.API.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiController]
|
||||
public class ReportsController : ControllerBase
|
||||
{
|
||||
// GET: api/Reports
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
// GET: api/Reports/5
|
||||
[HttpGet("{id}")]
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
}
|
||||
|
||||
// POST: api/Reports
|
||||
[HttpPost]
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT: api/Reports/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE: api/Reports/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OSI.API.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[ApiController]
|
||||
public class UsersController : ControllerBase
|
||||
{
|
||||
// GET: api/Users
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
// GET: api/Users/5
|
||||
[HttpGet("{id}")]
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
}
|
||||
|
||||
// POST: api/Users
|
||||
[HttpPost]
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT: api/Users/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE: api/Users/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace OSI.API.Controllers
|
||||
{
|
||||
public abstract class EndpointBase<A> : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public abstract IActionResult Get();
|
||||
|
||||
// GET: api/Clients/5
|
||||
[HttpGet("{id}")]
|
||||
public abstract IActionResult Get(int id);
|
||||
|
||||
// POST: api/Clients
|
||||
[HttpPost]
|
||||
public abstract IActionResult Create([FromBody] A input);
|
||||
|
||||
// PUT: api/Clients/5
|
||||
[HttpPut("{id}")]
|
||||
public abstract IActionResult Update([FromBody] A input);
|
||||
|
||||
// DELETE: api/Clients/5
|
||||
[HttpDelete("{id}")]
|
||||
public abstract IActionResult Delete(int id);
|
||||
|
||||
protected T FromJSON<T>(string input)
|
||||
{
|
||||
JsonSerializerOptions options = new()
|
||||
{
|
||||
Converters = {
|
||||
new JsonStringEnumConverter()
|
||||
}
|
||||
};
|
||||
|
||||
return JsonSerializer.Deserialize<T>(input, options);
|
||||
}
|
||||
|
||||
protected string ToJSON<T>(T input)
|
||||
{
|
||||
JsonSerializerOptions options = new()
|
||||
{
|
||||
WriteIndented = true,
|
||||
Converters = {
|
||||
new JsonStringEnumConverter()
|
||||
}
|
||||
};
|
||||
|
||||
return JsonSerializer.Serialize<T>(input, options);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>OSI_API</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="dbup" Version="4.5.0" />
|
||||
<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.33" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OSI-API.DAL\OSI-API.DAL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace OSI.API
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
namespace OSI.API
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
||||
services.AddControllers();
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "OSI.API", Version = "v1" });
|
||||
});
|
||||
|
||||
services.AddApiVersioning(options =>
|
||||
{
|
||||
options.ReportApiVersions = true;
|
||||
options.AssumeDefaultVersionWhenUnspecified = true;
|
||||
options.DefaultApiVersion = new ApiVersion(1, 0);
|
||||
});
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "OSI.API v1");
|
||||
c.RoutePrefix = "api";
|
||||
});
|
||||
}
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllerRoute(name: "default", pattern: "api/v{version:apiVersion}/{controller}/{action}/{id?}", null);
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
@ -1,2 +1,34 @@
|
||||
# OSI-API
|
||||
Open Source Invoice API
|
||||
|
||||
|
||||
#### Endpoints
|
||||
- Invoice
|
||||
- create
|
||||
- update
|
||||
- delete
|
||||
- PO
|
||||
- create
|
||||
- update
|
||||
- delete
|
||||
- Clients
|
||||
- create
|
||||
- update
|
||||
- delete
|
||||
- Reports
|
||||
- Income
|
||||
- by Client
|
||||
- Expenses
|
||||
- by Type
|
||||
- Expenses
|
||||
- Create
|
||||
- Update
|
||||
- delete
|
||||
- Users
|
||||
- create
|
||||
- update
|
||||
- delete
|
||||
- Payments
|
||||
- create
|
||||
- update
|
||||
- delete
|
Loading…
Reference in New Issue