Extend data service
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ReallifeGamemode.Database.Entities;
|
using ReallifeGamemode.Database.Entities;
|
||||||
using ReallifeGamemode.Database.Models;
|
using ReallifeGamemode.Database.Models;
|
||||||
using ReallifeGamemode.DataService.Types;
|
using ReallifeGamemode.DataService.Types;
|
||||||
@@ -31,7 +32,7 @@ namespace ReallifeGamemode.DataService.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public ActionResult<GetUserDataResponse> Data()
|
public ActionResult<GetUserDataResponse> Data()
|
||||||
{
|
{
|
||||||
User user = dbContext.Users.Where(u => u.Id == UserId).FirstOrDefault();
|
User user = dbContext.Users.Include(u => u.Faction).Include(u => u.FactionRank).Where(u => u.Id == UserId).FirstOrDefault();
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
@@ -42,7 +43,15 @@ namespace ReallifeGamemode.DataService.Controllers
|
|||||||
{
|
{
|
||||||
Name = user.Name,
|
Name = user.Name,
|
||||||
AdminLevel = user.AdminLevel,
|
AdminLevel = user.AdminLevel,
|
||||||
RegistrationDate = user.RegistrationDate
|
RegistrationDate = user.RegistrationDate,
|
||||||
|
BankMoney = user.GetBankAccount().Balance,
|
||||||
|
HandMoney = user.Handmoney,
|
||||||
|
FactionName = user.Faction?.Name,
|
||||||
|
FactionRankName = user.FactionRank?.RankName,
|
||||||
|
WantedLevel = user.Wanteds,
|
||||||
|
CarDrivingLicense = user.DriverLicenseVehicle,
|
||||||
|
BikeDrivingLicense = user.DriverLicenseBike,
|
||||||
|
PlaneLicense = user.FlyingLicensePlane
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,11 @@ namespace ReallifeGamemode.DataService
|
|||||||
public static IWebHost BuildWebHost(string[] args)
|
public static IWebHost BuildWebHost(string[] args)
|
||||||
{
|
{
|
||||||
return WebHost.CreateDefaultBuilder(args)
|
return WebHost.CreateDefaultBuilder(args)
|
||||||
.ConfigureLogging((ctx, l) =>
|
.ConfigureLogging((ctx, builder) =>
|
||||||
{
|
{
|
||||||
l.AddLog4Net(Path.Combine(ctx.HostingEnvironment.ContentRootPath, "log4net.config"));
|
builder.AddLog4Net(Path.Combine(ctx.HostingEnvironment.ContentRootPath, "log4net.config"));
|
||||||
})
|
})
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>()
|
||||||
.UseKestrel(k =>
|
|
||||||
{
|
|
||||||
k.Listen(IPAddress.Any, 5000);
|
|
||||||
})
|
|
||||||
.Build();
|
.Build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ namespace ReallifeGamemode.DataService
|
|||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|||||||
@@ -13,5 +13,29 @@ namespace ReallifeGamemode.DataService.Types
|
|||||||
public AdminLevel AdminLevel { get; set; }
|
public AdminLevel AdminLevel { get; set; }
|
||||||
|
|
||||||
public DateTime RegistrationDate { get; set; }
|
public DateTime RegistrationDate { get; set; }
|
||||||
|
|
||||||
|
public int RegisteredSince => (int)(DateTime.Now - RegistrationDate).TotalDays;
|
||||||
|
|
||||||
|
public int HandMoney { get; set; }
|
||||||
|
|
||||||
|
public int BankMoney { get; set; }
|
||||||
|
|
||||||
|
public string FactionName { get; set; }
|
||||||
|
|
||||||
|
public string FactionRankName { get; set; }
|
||||||
|
|
||||||
|
public string Job { get; set; }
|
||||||
|
|
||||||
|
public int WantedLevel { get; set; }
|
||||||
|
|
||||||
|
public bool CarDrivingLicense { get; set; }
|
||||||
|
|
||||||
|
public bool BikeDrivingLicense { get; set; }
|
||||||
|
|
||||||
|
public bool BoatLicense { get; set; }
|
||||||
|
|
||||||
|
public bool HelicopterLicense { get; set; }
|
||||||
|
|
||||||
|
public bool PlaneLicense { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user