Beta 1.0.0.4

1. BillsController - > Endpoints
2. NoticeboardController -  > Endpoints
3. ReportsController - > EndPoints
4.TransactionController -> Endpoints
5. UsersController - > Endpoints
This commit is contained in:
2024-03-09 23:30:19 +05:30
parent 8fa72ae97e
commit 10c3957ce1
13 changed files with 376 additions and 11 deletions
+22 -1
View File
@@ -1,7 +1,6 @@
using APISocietyToolBox.Data; using APISocietyToolBox.Data;
using APISocietyToolBox.Models; using APISocietyToolBox.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Security.Cryptography;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json; using Newtonsoft.Json;
using Microsoft.Data.SqlClient; using Microsoft.Data.SqlClient;
@@ -45,6 +44,28 @@ namespace APISocietyToolBox.Controllers
} }
[HttpGet("GetBillDetails"), Authorize]
public async Task<ActionResult<List<MemberBillsListModel>>> GetBillDetails(string BillID)
{
try
{
var pQueryResponse = await _Context.GetBillDetails
.FromSqlRaw("EXEC sp_getMemberBillList @BillID",
new SqlParameter("@BillID", System.Data.SqlDbType.VarChar) { Value = BillID })
.ToListAsync();
return Ok(pQueryResponse);
}
catch (Exception ex)
{
return StatusCode(500, ex.Message);
}
}
} }
+132
View File
@@ -0,0 +1,132 @@
using APISocietyToolBox.Data;
using APISocietyToolBox.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Microsoft.Data.SqlClient;
using Microsoft.AspNetCore.Authorization;
namespace APISocietyToolBox.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class NoticeBoardController : Controller
{
private readonly DataContext _Context;
public NoticeBoardController(DataContext context)
{
_Context = context;
}
[HttpPost("CreateNoticeMessage"), Authorize]
public async Task<ActionResult<ResponseNoticeBoardModel>> CreateNoticeMessage(Int32 PropertyID,Int32 UserID,string NoticeMessage)
{
try
{
var pQueryResponse = await _Context.DbNoticeBoard.FromSqlRaw("EXEC sp_CreateNoticeMessage @PropertyID,@UserID,@NoticeMessage",
new SqlParameter("@PropertyID", System.Data.SqlDbType.BigInt) { Value = PropertyID },
new SqlParameter("@UserID", System.Data.SqlDbType.BigInt) { Value = UserID },
new SqlParameter("@NoticeMessage", System.Data.SqlDbType.VarChar) { Value = NoticeMessage })
.ToListAsync();
var summary = pQueryResponse.FirstOrDefault();
if (pQueryResponse[0].Status != 200)
{
return BadRequest(summary);
}
else
{
return Ok(summary);
}
}
catch (Exception ex)
{
return StatusCode(500, (ex.Message));
}
}
[HttpPut("UpdateNoticeMessage"), Authorize]
public async Task<ActionResult<ResponseNoticeBoardModel>> UpdateNoticeMessage(Int32 PropertyID, Int32 UserID, string NoticeMessage, Int32 NoticeID)
{
try
{
var pQueryResponse = await _Context.DbNoticeBoard.FromSqlRaw("EXEC sp_AlterNoticeMessage @PropertyID,@UserID,@NoticeMessage,@NoticeID",
new SqlParameter("@PropertyID", System.Data.SqlDbType.BigInt) { Value = PropertyID },
new SqlParameter("@UserID", System.Data.SqlDbType.BigInt) { Value = UserID },
new SqlParameter("@NoticeMessage", System.Data.SqlDbType.VarChar) { Value = NoticeMessage },
new SqlParameter("@NoticeID", System.Data.SqlDbType.BigInt) { Value = NoticeID })
.ToListAsync();
var summary = pQueryResponse.FirstOrDefault();
if (pQueryResponse[0].Status != 200)
{
return BadRequest(summary);
}
else
{
return Ok(summary);
}
}
catch (Exception ex)
{
return StatusCode(500, (ex.Message));
}
}
[HttpDelete("DeleteNoticeMessage"), Authorize]
public async Task<ActionResult<ResponseNoticeBoardModel>> DeleteNoticeMessage(Int64 NoticeID, Int64 UserID)
{
try
{
var pQueryResponse = await _Context.DbNoticeBoard.FromSqlRaw("EXEC sp_DeleteNoticeMessage @NoticeID,@UserID",
new SqlParameter("@NoticeID", System.Data.SqlDbType.BigInt) { Value = NoticeID },
new SqlParameter("@UserID", System.Data.SqlDbType.BigInt) { Value = UserID })
.ToListAsync();
var summary = pQueryResponse.FirstOrDefault();
if (pQueryResponse[0].Status != 200)
{
return BadRequest(summary);
}
else
{
return Ok(summary);
}
}
catch (Exception ex)
{
return StatusCode(500,(ex.Message));
}
}
[HttpGet("GetNoticeMessageList"), Authorize]
public async Task<ActionResult<List<NoticeBoardMessageModel>>> GetNoticeMessageList(Int64 PropertyID)
{
try
{
var pQueryResponse = await _Context.GetNoticeBoardMessages.FromSqlRaw("EXEC sp_getNoticeMessagesList @PropertyID",
new SqlParameter("@PropertyID", System.Data.SqlDbType.BigInt) { Value = PropertyID })
.ToListAsync();
return Ok(pQueryResponse);
}
catch (Exception ex)
{
return StatusCode(500, (ex.Message));
}
}
}
}
+42
View File
@@ -0,0 +1,42 @@
using APISocietyToolBox.Data;
using APISocietyToolBox.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Microsoft.Data.SqlClient;
using Microsoft.AspNetCore.Authorization;
namespace APISocietyToolBox.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class PropertyUnitsController : Controller
{
private readonly DataContext _Context;
public PropertyUnitsController(DataContext context)
{
_Context = context;
}
[HttpGet("GetPropertyUnitsForUser"), Authorize]
public async Task<ActionResult<List<NoticeBoardMessageModel>>> GetPropertyUnitsForUser(Int64 UserID)
{
try
{
var pQueryResponse = await _Context.GetPropertyUnitsForUsers.FromSqlRaw("EXEC sp_getPropertyUnitsForUser @UserID",
new SqlParameter("@UserID", System.Data.SqlDbType.BigInt) { Value = UserID })
.ToListAsync();
return Ok(pQueryResponse);
}
catch (Exception ex)
{
return StatusCode(500, (ex.Message));
}
}
}
}
+45
View File
@@ -0,0 +1,45 @@
using APISocietyToolBox.Data;
using APISocietyToolBox.Models;
using Microsoft.AspNetCore.Mvc;
using System.Security.Cryptography;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Microsoft.Data.SqlClient;
using Microsoft.AspNetCore.Authorization;
namespace APISocietyToolBox.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ReportsController : Controller
{
private readonly DataContext _Context;
public ReportsController(DataContext context)
{
_Context = context;
}
[HttpGet("GetPropertyUnitLedgerReport"), Authorize]
public async Task<ActionResult<List<PropertyUnitLedgerReportsModel>>> GetPropertyUnitLedgerReport( Int32 PropertyUnitID, DateTime FromDate, DateTime ToDate)
{
try
{
var pQueryResponse = await _Context.GetPropertyUnitLedgerReport
.FromSqlRaw("EXEC sp_GeneratePropertyUnitLedger @FromDate,@ToDate,@PropertyUnitID",
new SqlParameter("@FromDate", System.Data.SqlDbType.Date) { Value = FromDate },
new SqlParameter("@ToDate", System.Data.SqlDbType.Date) { Value = ToDate },
new SqlParameter("@PropertyUnitID", System.Data.SqlDbType.BigInt) { Value = PropertyUnitID })
.ToListAsync();
return Ok(pQueryResponse);
}
catch (Exception ex)
{
return StatusCode(500, ex.Message);
}
}
}
}
-1
View File
@@ -48,6 +48,5 @@ namespace APISocietyToolBox.Controllers
} }
} }
} }
+30 -1
View File
@@ -57,7 +57,7 @@ namespace APISocietyToolBox.Controllers
} }
[HttpPost("AlterUser")] [HttpPut("AlterUser")]
public async Task<ActionResult<string>> AlterUser(UserRequestModel UserRequest) public async Task<ActionResult<string>> AlterUser(UserRequestModel UserRequest)
{ {
CreatePasswordHash(UserRequest.LoginPassword, out byte[] passwordHash, out byte[] passwordSalt); CreatePasswordHash(UserRequest.LoginPassword, out byte[] passwordHash, out byte[] passwordSalt);
@@ -94,6 +94,35 @@ namespace APISocietyToolBox.Controllers
} }
[HttpPut("UpdateUserMemberMapping")]
public async Task<ActionResult<string>> UpdateUserMemberMapping(List<UserMemberMappingModel> UserMappingRequest)
{
string pStrJSONUser = JsonConvert.SerializeObject(UserMappingRequest);
//pStrJSONUser = Regex.Replace(pStrJSONUser, @"[^\x20-\x7E]", "");
string pStrUserXML = ConvertFunctions.ConvertJsonArrayToXmlR1(pStrJSONUser, "USER", "USERMAPPINGDETAILS");
//UserResponseModel UserResponse = new UserResponseModel();
var pQueryResponse = await _Context.UserCRUD.FromSqlRaw("EXEC sp_UpdateUserMapping @XMLData",
new SqlParameter("@XMLData", System.Data.SqlDbType.Xml) { Value = pStrUserXML })
.ToListAsync();
//var oUserResponse = JsonConvert.DeserializeObject<UserResponseModel>(pQueryResponse?.ToString());
if (pQueryResponse[0].Status == 200)
{
return Ok(pQueryResponse);
}
else
{
return BadRequest(pQueryResponse);
}
}
private void CreatePasswordHash(string password, out byte[] passwordHash, out byte[] passwordSalt) private void CreatePasswordHash(string password, out byte[] passwordHash, out byte[] passwordSalt)
{ {
using (var hmac = new HMACSHA512()) using (var hmac = new HMACSHA512())
+4 -2
View File
@@ -15,9 +15,11 @@ namespace APISocietyToolBox.Data
public DbSet<DashBoardTransactionsModel> getDashboardTransactions { get; set; } public DbSet<DashBoardTransactionsModel> getDashboardTransactions { get; set; }
public DbSet<MemberBillsListModel> GetMemberBillList { get; set; } public DbSet<MemberBillsListModel> GetMemberBillList { get; set; }
public DbSet<BillsDetailsModel> GetBillDetails { get; set; } public DbSet<BillsDetailsModel> GetBillDetails { get; set; }
public DbSet<ResponseNoticeBoardModel> DbNoticeBoard { get; set; }
public DbSet<NoticeBoardMessageModel> GetNoticeBoardMessages { get; set; }
public DbSet<MemberTransactionsListModel> GetMemberTransactionsList { get; set; } public DbSet<MemberTransactionsListModel> GetMemberTransactionsList { get; set; }
public DbSet<PropertyUnitLedgerReportsModel> GetPropertyUnitLedgerReport { get; set; }
public DbSet<PropertyUnitUserModel> GetPropertyUnitsForUsers { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<UserTokenModel>().HasNoKey(); modelBuilder.Entity<UserTokenModel>().HasNoKey();
+33
View File
@@ -145,6 +145,39 @@ namespace APISocietyToolBox.Functions
} }
public static string ConvertJsonArrayToXmlR1(string jsonArray, string rootElementName, string itemElementName)
{
// Parse JSON array to JArray
JArray array = JArray.Parse(jsonArray);
// Create the root XML element with the user-defined name
XElement rootElement = new XElement(rootElementName);
// Convert each JSON object in the array to XML elements
foreach (JObject item in array)
{
// Create an item element for each item in the array
XElement itemElement = new XElement(itemElementName);
// Convert JSON properties to XML elements with values for each item
foreach (var property in item.Properties())
{
// Add property value to XML
itemElement.Add(new XElement(property.Name, property.Value.ToString()));
}
// Add the item element to the root element
rootElement.Add(itemElement);
}
// Convert the XElement to an XML string
string xmlString = rootElement.ToString();
return xmlString;
}
// Helper method to recursively convert JToken to XML // Helper method to recursively convert JToken to XML
private static XElement ConvertJTokenToXml(JToken token, XElement parentElement) private static XElement ConvertJTokenToXml(JToken token, XElement parentElement)
{ {
+23
View File
@@ -0,0 +1,23 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
namespace APISocietyToolBox.Models
{
public class ResponseNoticeBoardModel
{
public Int32 Status { get; set; }
public string? StatusMessage { get; set; }
[Key]
public Int32 NoticeID { get; set; }
}
public class NoticeBoardMessageModel
{
[Key]
public Int64 NoticeID { get; set; }
public string? NoticeMessage { get; set; }
public DateTime NoticeDate { get; set; }
}
}
+14
View File
@@ -0,0 +1,14 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
namespace APISocietyToolBox.Models
{
public class PropertyUnitUserModel
{
[Key]
public Int64 PropertyUnitID { get; set; }
public string? UnitNo { get; set; }
}
}
+19
View File
@@ -0,0 +1,19 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
namespace APISocietyToolBox.Models
{
public class PropertyUnitLedgerReportsModel
{
[Key]
public Int64? LEDROWID { get; set; }
public string? DocName { get; set; }
public DateTime? DocDate { get; set; }
public string? Remarks { get; set; }
public Decimal? DebitAmount { get; set; }
public Decimal? CreditAmount { get; set; }
public Decimal? BalanceAmount { get; set; }
}
}
+2
View File
@@ -19,4 +19,6 @@ namespace APISocietyToolBox.Models
public decimal TransactionAmount { get; set; } public decimal TransactionAmount { get; set; }
} }
} }
+6 -2
View File
@@ -69,7 +69,7 @@ namespace APISocietyToolBox.Models
public class UserResponseModel public class UserResponseModel
{ {
[Key] [Key]
public Int32 UserID { get; set; } public Int64 UserID { get; set; }
public string UserName { get; set; } = string.Empty; public string UserName { get; set; } = string.Empty;
public int Status { get; set; } public int Status { get; set; }
public string StatusMessage { get; set; } = string.Empty; public string StatusMessage { get; set; } = string.Empty;
@@ -88,7 +88,11 @@ namespace APISocietyToolBox.Models
public Int32 MemberID { get; set; } public Int32 MemberID { get; set; }
} }
public class UserMemberMappingModel
{
public Int32? UserID { get; set; }
public Int32 MemberID { get; set; }
}
public class UserTokensHistory public class UserTokensHistory
{ {
[Key] [Key]