Added admin endpoints
Added inventory and sales api endpoints
This commit is contained in:
parent
43f647d9b7
commit
f118635029
@ -77,6 +77,9 @@
|
||||
<Build Include="dbo\Stored Procedures\spSaleInsert.sql" />
|
||||
<Build Include="dbo\Stored Procedures\spSaleDetailInsert.sql" />
|
||||
<Build Include="dbo\Stored Procedures\spSaleLookUp.sql" />
|
||||
<Build Include="dbo\Stored Procedures\spInventoryGetAll.sql" />
|
||||
<Build Include="dbo\Stored Procedures\spInventoryInsert.sql" />
|
||||
<Build Include="dbo\Stored Procedures\spSaleSaleReport.sql" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<RefactorLog Include="RMData.refactorlog" />
|
||||
|
9
RMData/dbo/Stored Procedures/spInventoryGetAll.sql
Normal file
9
RMData/dbo/Stored Procedures/spInventoryGetAll.sql
Normal file
@ -0,0 +1,9 @@
|
||||
CREATE PROCEDURE [dbo].[spInventoryGetAll]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
SELECT [Id], [ProductId], [Quantity], [PurchasePrice], [PurchaseDate]
|
||||
from dbo.Inventory;
|
||||
|
||||
END
|
14
RMData/dbo/Stored Procedures/spInventoryInsert.sql
Normal file
14
RMData/dbo/Stored Procedures/spInventoryInsert.sql
Normal file
@ -0,0 +1,14 @@
|
||||
CREATE PROCEDURE [dbo].[spInventoryInsert]
|
||||
-- [ProductId], [Quantity], [PurchasePrice], [PurchaseDate]
|
||||
@ProductId int,
|
||||
@Quantity int,
|
||||
@PurchasePrice money,
|
||||
@PurchaseDate datetime2
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
INSERT INTO dbo.Inventory (ProductId, Quantity, PurchasePrice, PurchaseDate)
|
||||
VALUES (@ProductId, @Quantity, @PurchasePrice, @PurchaseDate);
|
||||
|
||||
END
|
10
RMData/dbo/Stored Procedures/spSaleSaleReport.sql
Normal file
10
RMData/dbo/Stored Procedures/spSaleSaleReport.sql
Normal file
@ -0,0 +1,10 @@
|
||||
CREATE PROCEDURE [dbo].[spSaleSaleReport]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
SELECT [S].[SaleDate], [S].[SubTotal], [S].[Tax], [S].[Total], [U].FirstName, [U].LastName, [U].EmailAddress
|
||||
FROM dbo.Sale AS S
|
||||
INNER JOIN dbo.[User] AS U
|
||||
ON S.CashierId = U.Id
|
||||
END
|
27
RMDataManager/Controllers/InventoryController.cs
Normal file
27
RMDataManager/Controllers/InventoryController.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using RMDataManagerLibrary.DataAcccess;
|
||||
using RMDataManagerLibrary.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace RMDataManager.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
public class InventoryController : ApiController
|
||||
{
|
||||
public List<InventoryModel> Get()
|
||||
{
|
||||
InventoryData data = new InventoryData();
|
||||
return data.GetInventory();
|
||||
}
|
||||
|
||||
public void Post(InventoryModel item)
|
||||
{
|
||||
InventoryData data = new InventoryData();
|
||||
data.SaveInventoryRecord(item);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,5 +20,13 @@ namespace RMDataManager.Controllers
|
||||
|
||||
data.SaveSale(sale, cashierId);
|
||||
}
|
||||
|
||||
[Route("GetSalesReport")]
|
||||
public List<SaleReportModel> GetSalesReport()
|
||||
{
|
||||
SaleData data = new SaleData();
|
||||
|
||||
return data.GetSaleReport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,6 +213,7 @@
|
||||
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
|
||||
<Compile Include="Controllers\AccountController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\InventoryController.cs" />
|
||||
<Compile Include="Controllers\ProductController.cs" />
|
||||
<Compile Include="Controllers\SaleController.cs" />
|
||||
<Compile Include="Controllers\UserController.cs" />
|
||||
|
29
RMDataManagerLibrary/DataAcccess/InventoryData.cs
Normal file
29
RMDataManagerLibrary/DataAcccess/InventoryData.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using RMDataManagerLibrary.Internal.DataAccess;
|
||||
using RMDataManagerLibrary.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RMDataManagerLibrary.DataAcccess
|
||||
{
|
||||
public class InventoryData
|
||||
{
|
||||
public List<InventoryModel> GetInventory()
|
||||
{
|
||||
SqlDataAccess sql = new SqlDataAccess();
|
||||
|
||||
var output = sql.LoadData<InventoryModel, dynamic>("dbo.spInventoryGetAll", new { }, "RMData");
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public void SaveInventoryRecord(InventoryModel item)
|
||||
{
|
||||
SqlDataAccess sql = new SqlDataAccess();
|
||||
|
||||
sql.SaveData("dbo.spInventoryInsert", item, "RMData");
|
||||
}
|
||||
}
|
||||
}
|
@ -80,6 +80,15 @@ namespace RMDataManagerLibrary.DataAcccess
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<SaleReportModel> GetSaleReport()
|
||||
{
|
||||
SqlDataAccess sql = new SqlDataAccess();
|
||||
|
||||
var output = sql.LoadData<SaleReportModel, dynamic>("dbo.spSaleSaleReport", new { }, "RMData");
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
16
RMDataManagerLibrary/Models/InventoryModel.cs
Normal file
16
RMDataManagerLibrary/Models/InventoryModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RMDataManagerLibrary.Models
|
||||
{
|
||||
public class InventoryModel
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
public decimal PurchasePrice { get; set; }
|
||||
public DateTime PurchaseDate { get; set; }
|
||||
}
|
||||
}
|
19
RMDataManagerLibrary/Models/SaleReportModel.cs
Normal file
19
RMDataManagerLibrary/Models/SaleReportModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RMDataManagerLibrary.Models
|
||||
{
|
||||
public class SaleReportModel
|
||||
{
|
||||
public DateTime SaleDate { get; set; }
|
||||
public decimal SubTotal { get; set; }
|
||||
public decimal Tax { get; set; }
|
||||
public decimal Total { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string EmailAddress { get; set; }
|
||||
}
|
||||
}
|
@ -46,14 +46,17 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigHelper.cs" />
|
||||
<Compile Include="DataAcccess\InventoryData.cs" />
|
||||
<Compile Include="DataAcccess\ProductData.cs" />
|
||||
<Compile Include="DataAcccess\SaleData.cs" />
|
||||
<Compile Include="DataAcccess\UserData.cs" />
|
||||
<Compile Include="Models\InventoryModel.cs" />
|
||||
<Compile Include="Models\ProductModel.cs" />
|
||||
<Compile Include="Models\SaleDBModel.cs" />
|
||||
<Compile Include="Models\SaleDetailDBModel.cs" />
|
||||
<Compile Include="Models\SaleDetailModel.cs" />
|
||||
<Compile Include="Models\SaleModel.cs" />
|
||||
<Compile Include="Models\SaleReportModel.cs" />
|
||||
<Compile Include="Models\UserModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Internal\DataAccess\SqlDataAccess.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user