Beta 1.0.0.3
Updates: 1, Dashboard 2. Idivdual transactions
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
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 BillsController : Controller
|
||||||
|
{
|
||||||
|
private readonly DataContext _Context;
|
||||||
|
public BillsController(DataContext context)
|
||||||
|
{
|
||||||
|
_Context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("GetMemberBillList"), Authorize]
|
||||||
|
public async Task<ActionResult<List<MemberBillsListModel>>> GetMemberBillList(Int32 PropertyID, Int32 PropertyUnitID, DateTime FromDate, DateTime ToDate)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pQueryResponse = await _Context.GetMemberBillList
|
||||||
|
.FromSqlRaw("EXEC sp_getMemberBillList @PropertyID,@PropertyUnitID,@FromDate,@ToDate",
|
||||||
|
new SqlParameter("@PropertyID", System.Data.SqlDbType.BigInt) { Value = PropertyID },
|
||||||
|
new SqlParameter("@PropertyUnitID", System.Data.SqlDbType.BigInt) { Value = PropertyUnitID },
|
||||||
|
new SqlParameter("@FromDate", System.Data.SqlDbType.Date) { Value = FromDate },
|
||||||
|
new SqlParameter("@ToDate", System.Data.SqlDbType.Date) { Value = ToDate })
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return Ok(pQueryResponse);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
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 DashboardController : Controller
|
||||||
|
{
|
||||||
|
private readonly DataContext _Context;
|
||||||
|
public DashboardController(DataContext context)
|
||||||
|
{
|
||||||
|
_Context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("GetDashboardOutstandingSummary"), Authorize]
|
||||||
|
public async Task<ActionResult<List<DashBoardOutandingSummaryModel>>> GetDashboardOutstandingSummary(Int32 PropertyID, Int32 UserID)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pQueryResponse = await _Context.getDashboardOutstandingSummary
|
||||||
|
.FromSqlRaw("EXEC sp_getDashboardMemberOustandingSummary @PropertyID,@UserID",
|
||||||
|
new SqlParameter("@PropertyID", System.Data.SqlDbType.BigInt) { Value = PropertyID },
|
||||||
|
new SqlParameter("@UserID", System.Data.SqlDbType.BigInt) { Value = UserID })
|
||||||
|
.ToListAsync();
|
||||||
|
//var summary = pQueryResponse.FirstOrDefault();
|
||||||
|
|
||||||
|
|
||||||
|
return Ok(pQueryResponse);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("GetDashboardTransactions"),Authorize]
|
||||||
|
public async Task<ActionResult<List<DashBoardTransactionsModel>>> GetDashboardTransactions(Int32 PropertyID, Int32 UserID)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pQueryResponse = await _Context.getDashboardTransactions
|
||||||
|
.FromSqlRaw("EXEC sp_getDashboardRecentTransactions @PropertyID,@UserID",
|
||||||
|
new SqlParameter("@PropertyID", System.Data.SqlDbType.BigInt) { Value = PropertyID },
|
||||||
|
new SqlParameter("@UserID", System.Data.SqlDbType.BigInt) { Value = UserID })
|
||||||
|
.ToListAsync();
|
||||||
|
var summary = pQueryResponse.FirstOrDefault();
|
||||||
|
|
||||||
|
|
||||||
|
return Ok(pQueryResponse);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,6 +61,7 @@ namespace APISocietyToolBox.Controllers
|
|||||||
user.UserRole = pQueryResponse[0].UserRole;
|
user.UserRole = pQueryResponse[0].UserRole;
|
||||||
user.UserRoleID = pQueryResponse[0].UserRoleID;
|
user.UserRoleID = pQueryResponse[0].UserRoleID;
|
||||||
user.PropertyID = pQueryResponse[0].PropertyID;
|
user.PropertyID = pQueryResponse[0].PropertyID;
|
||||||
|
user.MemberID = pQueryResponse[0].MemberID;
|
||||||
user.RefreshToken = Token;
|
user.RefreshToken = Token;
|
||||||
user.TokenExpires = refreshToken.Expires;
|
user.TokenExpires = refreshToken.Expires;
|
||||||
user.TokenCreated = refreshToken.Created;
|
user.TokenCreated = refreshToken.Created;
|
||||||
@@ -100,16 +101,16 @@ namespace APISocietyToolBox.Controllers
|
|||||||
//}
|
//}
|
||||||
LoginResponseModel usrResponse = new LoginResponseModel();
|
LoginResponseModel usrResponse = new LoginResponseModel();
|
||||||
UserModel usr = new UserModel();
|
UserModel usr = new UserModel();
|
||||||
usrResponse.UserName = user.UserName;
|
usrResponse.UserName = user.UserName!;
|
||||||
usrResponse.UserRole = user.UserRole;
|
usrResponse.UserRole = user.UserRole!;
|
||||||
|
|
||||||
string token = CreateToken(usrResponse);
|
string token = CreateToken(usrResponse);
|
||||||
var newRefreshToken = GenerateRefreshToken();
|
var newRefreshToken = GenerateRefreshToken();
|
||||||
|
|
||||||
usr.UserID = pQueryResponse[0].UserID;
|
usr.UserID = pQueryResponse[0].UserID;
|
||||||
usr.UserRoleID = pQueryResponse[0].UserRoleID;
|
usr.UserRoleID = pQueryResponse[0].UserRoleID;
|
||||||
usr.UserName = user.UserName;
|
usr.UserName = user.UserName!;
|
||||||
usr.UserRole = user.UserRole;
|
usr.UserRole = user.UserRole!;
|
||||||
usr.PropertyID = pQueryResponse[0].PropertyID;
|
usr.PropertyID = pQueryResponse[0].PropertyID;
|
||||||
|
|
||||||
usr.RefreshToken = token.ToString();
|
usr.RefreshToken = token.ToString();
|
||||||
@@ -148,7 +149,7 @@ namespace APISocietyToolBox.Controllers
|
|||||||
|
|
||||||
|
|
||||||
//Response.Cookies.Append("refreshToken", newRefreshToken.Token, cookieOptions);
|
//Response.Cookies.Append("refreshToken", newRefreshToken.Token, cookieOptions);
|
||||||
UserTokens oUserTokens = new UserTokens();
|
UserTokensHistory oUserTokens = new UserTokensHistory();
|
||||||
oUserTokens.UserID = usr.UserID;
|
oUserTokens.UserID = usr.UserID;
|
||||||
oUserTokens.UserRoleID = usr.UserRoleID;
|
oUserTokens.UserRoleID = usr.UserRoleID;
|
||||||
oUserTokens.PropertyID = usr.PropertyID;
|
oUserTokens.PropertyID = usr.PropertyID;
|
||||||
@@ -157,7 +158,7 @@ namespace APISocietyToolBox.Controllers
|
|||||||
oUserTokens.TokenExpires = usr.TokenExpires;
|
oUserTokens.TokenExpires = usr.TokenExpires;
|
||||||
|
|
||||||
|
|
||||||
_Context.UserTokens.Add(oUserTokens);
|
_Context.UserTokensHistory.Add(oUserTokens);
|
||||||
_Context.SaveChanges();
|
_Context.SaveChanges();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
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 TransactionsController : Controller
|
||||||
|
{
|
||||||
|
private readonly DataContext _Context;
|
||||||
|
public TransactionsController(DataContext context)
|
||||||
|
{
|
||||||
|
_Context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("GetMemberTransactionList"), Authorize]
|
||||||
|
public async Task<ActionResult<List<MemberTransactionsListModel>>> GetMemberTransactionList(Int32 PropertyID, Int32 PropertyUnitID,Int32 TransactionTypeID,DateTime FromDate,DateTime ToDate)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pQueryResponse = await _Context.GetMemberTransactionsList
|
||||||
|
.FromSqlRaw("EXEC sp_getMemberTransactionList @PropertyID,@PropertyUnitID,@TransactionTypeID,@FromDate,@ToDate",
|
||||||
|
new SqlParameter("@PropertyID", System.Data.SqlDbType.BigInt) { Value = PropertyID },
|
||||||
|
new SqlParameter("@PropertyUnitID", System.Data.SqlDbType.BigInt) { Value = PropertyUnitID },
|
||||||
|
new SqlParameter("@TransactionTypeID", System.Data.SqlDbType.BigInt) { Value = TransactionTypeID },
|
||||||
|
new SqlParameter("@FromDate", System.Data.SqlDbType.Date) { Value = FromDate },
|
||||||
|
new SqlParameter("@ToDate", System.Data.SqlDbType.Date) { Value = ToDate })
|
||||||
|
.ToListAsync();
|
||||||
|
var summary = pQueryResponse.FirstOrDefault();
|
||||||
|
|
||||||
|
|
||||||
|
return Ok(pQueryResponse);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-1
@@ -10,7 +10,13 @@ namespace APISocietyToolBox.Data
|
|||||||
public DbSet<UserResponseModel> UserCRUD { get; set; }
|
public DbSet<UserResponseModel> UserCRUD { get; set; }
|
||||||
public DbSet<LoginResponseModel> LoginUserValidate { get; set; }
|
public DbSet<LoginResponseModel> LoginUserValidate { get; set; }
|
||||||
public DbSet<UserTokenModel> getUserToken { get; set; }
|
public DbSet<UserTokenModel> getUserToken { get; set; }
|
||||||
public DbSet<UserTokens> UserTokens { get; set; }
|
public DbSet<UserTokensHistory> UserTokensHistory { get; set; }
|
||||||
|
public DbSet<DashBoardOutandingSummaryModel> getDashboardOutstandingSummary { get; set; }
|
||||||
|
public DbSet<DashBoardTransactionsModel> getDashboardTransactions { get; set; }
|
||||||
|
public DbSet<MemberBillsListModel> GetMemberBillList { get; set; }
|
||||||
|
public DbSet<BillsDetailsModel> GetBillDetails { get; set; }
|
||||||
|
public DbSet<MemberTransactionsListModel> GetMemberTransactionsList { get; set; }
|
||||||
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
|
||||||
|
namespace APISocietyToolBox.Models
|
||||||
|
{
|
||||||
|
public class MemberBillsListModel
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string? BillID { get; set; }
|
||||||
|
public string? BillNo { get; set; }
|
||||||
|
public DateTime BillDate { get; set; }
|
||||||
|
public DateTime BillMonth { get; set; }
|
||||||
|
public string? MemberName { get; set; }
|
||||||
|
public string? UnitNo { get; set; }
|
||||||
|
public decimal BillAmount { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BillsDetailsModel
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string? BillID { get; set; }
|
||||||
|
public Int32 LedgerID { get; set; }
|
||||||
|
public string? LedgerName { get; set; }
|
||||||
|
public string? Remarks { get; set;}
|
||||||
|
public decimal LedgerAmount { get; set;}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
|
||||||
|
namespace APISocietyToolBox.Models
|
||||||
|
{
|
||||||
|
public class DashBoardOutandingSummaryModel
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public Int64 PropertyUnitID { get; set; }
|
||||||
|
public string? BuildingNo { get; set; }
|
||||||
|
public string? UnitNo { get; set; }
|
||||||
|
public string? MemberName { get; set; }
|
||||||
|
public decimal ClosingBal { get; set; }
|
||||||
|
public decimal LastReceiptAmt { get; set; }
|
||||||
|
public DateTime? LastReceiptDate { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DashBoardTransactionsModel
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string DocID { get; set; }
|
||||||
|
public string? DocNo { get; set; }
|
||||||
|
public DateTime DocDate { get; set; }
|
||||||
|
public string? MemberName { get; set; }
|
||||||
|
public string? UnitNo { get; set; }
|
||||||
|
public decimal DocAmount { get; set; }
|
||||||
|
public string? TRType { get; set; }
|
||||||
|
public Int32 NewTRStatus { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
|
||||||
|
namespace APISocietyToolBox.Models
|
||||||
|
{
|
||||||
|
public class MemberTransactionsListModel
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string? TransactionID { get; set; }
|
||||||
|
public string? TransactionNo { get; set; }
|
||||||
|
public DateTime TransactionDate { get; set; }
|
||||||
|
public Int32 TransactionTypeID { get; set; }
|
||||||
|
public string? MemberName { get; set; }
|
||||||
|
public string? CashBankLedger { get; set; }
|
||||||
|
public string? Remarks { get; set; }
|
||||||
|
public string? UnitNo { get; set; }
|
||||||
|
public decimal TransactionAmount { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
-18
@@ -9,15 +9,15 @@ namespace APISocietyToolBox.Models
|
|||||||
public class UserModel
|
public class UserModel
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public Int32? UserID { get; set; } = null;
|
public long? UserID { get; set; } = null;
|
||||||
public string UserName { get; set; } = string.Empty;
|
public string UserName { get; set; } = string.Empty;
|
||||||
public string LoginName { get; set; } = string.Empty;
|
public string LoginName { get; set; } = string.Empty;
|
||||||
public string LoginPassword { get; set; } = string.Empty;
|
public string LoginPassword { get; set; } = string.Empty;
|
||||||
public string PasswordSalt { get; set; } = string.Empty;
|
public string PasswordSalt { get; set; } = string.Empty;
|
||||||
public string UserRole { get; set; } = string.Empty;
|
public string UserRole { get; set; } = string.Empty;
|
||||||
public Int32? UserRoleID { get; set; }
|
public long? UserRoleID { get; set; }
|
||||||
public Int32? PropertyID { get; set; }
|
public long? PropertyID { get; set; }
|
||||||
public int MemberID { get; set; }
|
public long MemberID { get; set; }
|
||||||
public string? RefreshToken { get; set; } = string.Empty;
|
public string? RefreshToken { get; set; } = string.Empty;
|
||||||
public DateTime? TokenCreated { get; set; }
|
public DateTime? TokenCreated { get; set; }
|
||||||
public DateTime? TokenExpires { get; set; }
|
public DateTime? TokenExpires { get; set; }
|
||||||
@@ -39,10 +39,10 @@ namespace APISocietyToolBox.Models
|
|||||||
public string StatusMessage { get; set; } = string.Empty;
|
public string StatusMessage { get; set; } = string.Empty;
|
||||||
public string? UserName { get; set; } = string.Empty;
|
public string? UserName { get; set; } = string.Empty;
|
||||||
public string? UserRole { get; set; } = string.Empty;
|
public string? UserRole { get; set; } = string.Empty;
|
||||||
public Int32? UserRoleID { get; set; } = null;
|
public long? UserRoleID { get; set; } = null;
|
||||||
public Int32? UserID { get; set; } = null;
|
public long? UserID { get; set; } = null;
|
||||||
public int PropertyID { get; set; }
|
public Int32? PropertyID { get; set; }
|
||||||
public int MemberID { get; set; }
|
//public Int32 MemberID { get; set; }
|
||||||
public string? RefreshToken { get; set; } = string.Empty;
|
public string? RefreshToken { get; set; } = string.Empty;
|
||||||
public DateTime? TokenCreated { get; set; }
|
public DateTime? TokenCreated { get; set; }
|
||||||
public DateTime? TokenExpires { get; set; }
|
public DateTime? TokenExpires { get; set; }
|
||||||
@@ -51,24 +51,25 @@ namespace APISocietyToolBox.Models
|
|||||||
|
|
||||||
public class LoginResponseModel
|
public class LoginResponseModel
|
||||||
{
|
{
|
||||||
|
[Key]
|
||||||
public int? Status { get; set; }
|
public int? Status { get; set; }
|
||||||
public string StatusMessage { get; set; } = string.Empty;
|
public string StatusMessage { get; set; } = string.Empty;
|
||||||
[Key]
|
|
||||||
public Int32 UserID { get; set; }
|
public long UserID { get; set; }
|
||||||
public Int32 UserRoleID { get; set; }
|
public long UserRoleID { get; set; }
|
||||||
public string UserRole { get; set; } = string.Empty;
|
public string UserRole { get; set; } = string.Empty;
|
||||||
public string UserName { get; set; } = string.Empty;
|
public string UserName { get; set; } = string.Empty;
|
||||||
public string LoginPassword { get; set; } = string.Empty;
|
public string LoginPassword { get; set; } = string.Empty;
|
||||||
public string PasswordSalt { get; set; } = string.Empty;
|
public string PasswordSalt { get; set; } = string.Empty;
|
||||||
public Int32 PropertyID { get; set; }
|
public long PropertyID { get; set; }
|
||||||
public Int32 MemberID { get; set; }
|
public long MemberID { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserResponseModel
|
public class UserResponseModel
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public Int64 UserID { get; set; }
|
public Int32 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,14 +89,14 @@ namespace APISocietyToolBox.Models
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserTokens
|
public class UserTokensHistory
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public Int32 UserTokenID { get; set; }
|
public Int32 UserTokenID { get; set; }
|
||||||
public Int64? UserID { get; set; }
|
public long? UserID { get; set; }
|
||||||
public Int32? UserRoleID { get; set; }
|
public long? UserRoleID { get; set; }
|
||||||
public Int32? PropertyID { get; set; }
|
public long? PropertyID { get; set; }
|
||||||
public string? RefreshToken { get; set; }
|
public string? RefreshToken { get; set; }
|
||||||
public DateTime? TokenExpires { get; set; }
|
public DateTime? TokenExpires { get; set; }
|
||||||
public DateTime? TokenCreated { get; set; }
|
public DateTime? TokenCreated { get; set; }
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Microsoft.OpenApi.Models;
|
|||||||
using Swashbuckle.AspNetCore.Filters;
|
using Swashbuckle.AspNetCore.Filters;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using APISocietyToolBox.Data;
|
using APISocietyToolBox.Data;
|
||||||
|
using APISocietyToolBox.Services.UserService;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ Log.Logger = new LoggerConfiguration()
|
|||||||
builder.Host.UseSerilog();
|
builder.Host.UseSerilog();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
builder.Services.AddScoped<IUserService, UserService>();
|
||||||
builder.Services.AddDbContext<DataContext>(options =>
|
builder.Services.AddDbContext<DataContext>(options =>
|
||||||
{
|
{
|
||||||
options.UseSqlServer(builder.Configuration.GetConnectionString("SQLServerConnection"));
|
options.UseSqlServer(builder.Configuration.GetConnectionString("SQLServerConnection"));
|
||||||
@@ -74,6 +76,7 @@ if (app.Environment.IsDevelopment())
|
|||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
}
|
}
|
||||||
|
app.UseAuthentication();
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace APISocietyToolBox.Services.UserService
|
||||||
|
{
|
||||||
|
public class IUserService
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
|
|
||||||
|
namespace APISocietyToolBox.Services.UserService
|
||||||
|
{
|
||||||
|
public class UserService : IUserService
|
||||||
|
{
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
public UserService(IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetMyName()
|
||||||
|
{
|
||||||
|
var result = string.Empty;
|
||||||
|
if (_httpContextAccessor.HttpContext != null)
|
||||||
|
{
|
||||||
|
result = _httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.Name);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"SQLServerConnection": "server=ROGFLOWX13\\SQL2014;Database=SocietyToolbox;User Id=sa;Password=ift@!234;TrustServerCertificate=True"
|
"SQLServerConnection": "server=ROGFLOWX13\\SQL2014;Database=SocietyToolbox;User Id=sa;Password=ift@!234;TrustServerCertificate=True"
|
||||||
},
|
},
|
||||||
"AppSettings": {
|
"AppSettings": {
|
||||||
"Token": "MXZUOPUW1K9R5JJFACTVDIZKLABYPADTNZBSMA9869EZFKWJ3R9VG2KY2NRCKUS2"
|
"Token": "8D9759A17055346C1D620EAE9E28B11B6C3F359D804D3A91E2AFE5FBB98DAFD9"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|||||||
Reference in New Issue
Block a user