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.Models;
using Microsoft.AspNetCore.Mvc;
using System.Security.Cryptography;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
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)
{
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)
{
using (var hmac = new HMACSHA512())