save locations
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
|
||||
namespace ReallifeGamemode.DataService.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Produces("application/json")]
|
||||
[Route("DataService/[controller]")]
|
||||
public class LocationController : ControllerBase
|
||||
{
|
||||
private readonly DatabaseContext dbContext;
|
||||
|
||||
public LocationController(DatabaseContext dbContext)
|
||||
{
|
||||
this.dbContext = dbContext;
|
||||
}
|
||||
|
||||
[HttpGet("GetLocations")]
|
||||
public ActionResult<IEnumerable<string>> GetLocations()
|
||||
{
|
||||
var list = this.dbContext.Locations.OrderByDescending(l => l.Id);
|
||||
|
||||
List<string> locations = new List<string>();
|
||||
|
||||
foreach(var location in list)
|
||||
{
|
||||
locations.Add($"{location.Description.PadRight(20)} - {Math.Round(location.X, 2).ToString(CultureInfo.InvariantCulture)}, {Math.Round(location.Y, 2).ToString(CultureInfo.InvariantCulture)}, {Math.Round(location.Z, 2).ToString(CultureInfo.InvariantCulture)}");
|
||||
}
|
||||
|
||||
return locations;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace ReallifeGamemode.DataService.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("DataService/User")]
|
||||
[Route("DataService/[controller]")]
|
||||
[Produces("application/json")]
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user