Adding visited countries by robot + it stays #2
No files matched your search
@@ -0,0 +1,61 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using RobotsWantedLeague.Models;
|
||||||
|
using RobotsWantedLeague.Services;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace RobotsWantedLeague.Controllers;
|
||||||
|
|
||||||
|
public class AgentRequest
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Continent { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AgentsController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<AgentsController> _logger;
|
||||||
|
private readonly IAgentsService agentsService;
|
||||||
|
|
||||||
|
public AgentsController(ILogger<AgentsController> logger,
|
||||||
|
IAgentsService agentsService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
this.agentsService = agentsService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View(agentsService.Agents);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Agent(int id)
|
||||||
|
{
|
||||||
|
Agent? agent = agentsService.GetAgentById(id);
|
||||||
|
if (agent == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
return View(agent);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreateAgent()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult CreateAgent([FromBody] AgentRequest agent)
|
||||||
|
{
|
||||||
|
|
||||||
|
Agent r = agentsService.CreateAgent(agent.Name,
|
||||||
|
agent.Continent);
|
||||||
|
string htmxRedirectHeaderName = "HX-Redirect";
|
||||||
|
string redirectURL = "/agents/agent?id=" + r.Id;
|
||||||
|
Response.Headers.Add(htmxRedirectHeaderName, redirectURL);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,15 +2,17 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using RobotsWantedLeague.Models;
|
using RobotsWantedLeague.Models;
|
||||||
using RobotsWantedLeague.Services;
|
using RobotsWantedLeague.Services;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace RobotsWantedLeague.Controllers;
|
namespace RobotsWantedLeague.Controllers;
|
||||||
|
|
||||||
public class RobotRequest{
|
public class RobotRequest
|
||||||
|
{
|
||||||
|
public string Country { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
public int Weight { get; set; }
|
public int Weight { get; set; }
|
||||||
|
|
||||||
public string Country { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RobotsController : Controller
|
public class RobotsController : Controller
|
||||||
@@ -30,19 +32,26 @@ public class RobotsController : Controller
|
|||||||
return View(robotsService.Robots);
|
return View(robotsService.Robots);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Robot(int id){
|
public IActionResult Robot(int id)
|
||||||
Robot robot = robotsService.GetRobotById(id);
|
{
|
||||||
|
Robot? robot = robotsService.GetRobotById(id);
|
||||||
|
if (robot == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
return View(robot);
|
return View(robot);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateRobot(){
|
public IActionResult CreateRobot()
|
||||||
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult CreateRobot([FromBody] RobotRequest robot)
|
public IActionResult CreateRobot([FromBody] RobotRequest robot)
|
||||||
{
|
{
|
||||||
|
|
||||||
Robot r = robotsService.CreateRobot(robot.Name,
|
Robot r = robotsService.CreateRobot(robot.Name,
|
||||||
robot.Weight,
|
robot.Weight,
|
||||||
robot.Height,
|
robot.Height,
|
||||||
@@ -52,4 +61,12 @@ public class RobotsController : Controller
|
|||||||
Response.Headers.Add(htmxRedirectHeaderName, redirectURL);
|
Response.Headers.Add(htmxRedirectHeaderName, redirectURL);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult ChangeRobotCountry(int robotId, string newCountry)
|
||||||
|
{
|
||||||
|
robotsService.ChangeRobotCountry(robotId, newCountry);
|
||||||
|
return RedirectToAction("Robot", new { id = robotId });
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
namespace RobotsWantedLeague.Models;
|
||||||
|
|
||||||
|
public class Agent
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Continent { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public Agent(int Id, string Name, string Continent)
|
||||||
|
{
|
||||||
|
this.Id = Id;
|
||||||
|
this.Name = Name;
|
||||||
|
this.Continent = Continent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,22 +1,18 @@
|
|||||||
namespace RobotsWantedLeague.Models;
|
namespace RobotsWantedLeague.Models;
|
||||||
|
|
||||||
public class Robot{
|
public class Robot
|
||||||
public int Id { get; set;}
|
{
|
||||||
public string Name { get; set;}
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Weight { get; set; }
|
||||||
|
public int Height { get; set; }
|
||||||
|
public string Country { get; set; }
|
||||||
|
public string NewCountry { get; set; }
|
||||||
|
public List<string> VisitedCountries { get; set; } = new List<string>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Weight in kg.
|
|
||||||
*/
|
|
||||||
public int Weight { get; set;}
|
|
||||||
|
|
||||||
/**
|
public Robot(int Id, string Name, int Weight, int Height, string Country)
|
||||||
* Height in m.
|
{
|
||||||
*/
|
|
||||||
public int Height { get; set;}
|
|
||||||
|
|
||||||
public string Country { get; set;}
|
|
||||||
|
|
||||||
public Robot(int Id, string Name, int Weight, int Height, string Country){
|
|
||||||
this.Id = Id;
|
this.Id = Id;
|
||||||
this.Name = Name;
|
this.Name = Name;
|
||||||
this.Weight = Weight;
|
this.Weight = Weight;
|
||||||
@@ -24,4 +20,5 @@ public class Robot{
|
|||||||
this.Country = Country;
|
this.Country = Country;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
builder.Services.AddSingleton<IRobotsService, NotEmptyRobotsService>();
|
builder.Services.AddSingleton<IRobotsService, NotEmptyRobotsService>();
|
||||||
|
builder.Services.AddSingleton<IAgentsService, NotEmptyAgentsService>();
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
namespace RobotsWantedLeague.Services;
|
||||||
|
|
||||||
|
using RobotsWantedLeague.Models;
|
||||||
|
|
||||||
|
public class AgentsService: IAgentsService
|
||||||
|
{
|
||||||
|
private readonly List<Agent> agents;
|
||||||
|
private int idGenerator = 0;
|
||||||
|
public List<Agent> Agents { get => agents; }
|
||||||
|
|
||||||
|
public AgentsService()
|
||||||
|
{
|
||||||
|
agents = new List<Agent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int generateId(){
|
||||||
|
idGenerator = idGenerator + 1;
|
||||||
|
return idGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Agent CreateAgent(string name,
|
||||||
|
string continent)
|
||||||
|
{
|
||||||
|
var agent = new Agent(generateId(), name, continent);
|
||||||
|
agents.Add(agent);
|
||||||
|
return agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getIndexOfAgentById(int id){
|
||||||
|
int idx = 0;
|
||||||
|
foreach (Agent agent in agents){
|
||||||
|
if (agent.Id == id){
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
idx ++;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Agent? GetAgentById(int id){
|
||||||
|
int indexToDelete = getIndexOfAgentById(id);
|
||||||
|
if(indexToDelete == -1){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return agents[indexToDelete];
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeleteAgentById(int id){
|
||||||
|
int indexToDelete = getIndexOfAgentById(id);
|
||||||
|
if(indexToDelete == -1){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
agents.RemoveAt(indexToDelete);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace RobotsWantedLeague.Services;
|
||||||
|
using RobotsWantedLeague.Models;
|
||||||
|
|
||||||
|
public interface IAgentsService
|
||||||
|
{
|
||||||
|
public List<Agent> Agents { get; }
|
||||||
|
|
||||||
|
public Agent CreateAgent(string name,
|
||||||
|
string continent);
|
||||||
|
public Agent? GetAgentById(int id);
|
||||||
|
public bool DeleteAgentById(int id);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
namespace RobotsWantedLeague.Services;
|
||||||
|
|
||||||
|
using RobotsWantedLeague.Models;
|
||||||
|
|
||||||
|
public class NotEmptyAgentsService : IAgentsService
|
||||||
|
{
|
||||||
|
private readonly IAgentsService underlyingAgentsService;
|
||||||
|
public List<Agent> Agents { get => underlyingAgentsService.Agents; }
|
||||||
|
|
||||||
|
public NotEmptyAgentsService()
|
||||||
|
{
|
||||||
|
this.underlyingAgentsService = new AgentsService();
|
||||||
|
this.underlyingAgentsService.CreateAgent("Mulder", "Amérique du Nord");
|
||||||
|
this.underlyingAgentsService.CreateAgent("Scully", "Amérique du Sud");
|
||||||
|
this.underlyingAgentsService.CreateAgent("Doggett", "Antarctique");
|
||||||
|
this.underlyingAgentsService.CreateAgent("Reyes", "Europe");
|
||||||
|
this.underlyingAgentsService.CreateAgent("Skinner", "Asie");
|
||||||
|
this.underlyingAgentsService.CreateAgent("Spender", "Afrique");
|
||||||
|
this.underlyingAgentsService.CreateAgent("Kersh", "Océanie");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Agent CreateAgent(string name,
|
||||||
|
string continent)
|
||||||
|
{
|
||||||
|
return underlyingAgentsService.CreateAgent(name, continent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Agent? GetAgentById(int id)
|
||||||
|
{
|
||||||
|
return underlyingAgentsService.GetAgentById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeleteAgentById(int id)
|
||||||
|
{
|
||||||
|
return underlyingAgentsService.DeleteAgentById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+5
-3
@@ -1,15 +1,17 @@
|
|||||||
namespace RobotsWantedLeague.Services;
|
namespace RobotsWantedLeague.Services;
|
||||||
using RobotsWantedLeague.Models;
|
using RobotsWantedLeague.Models;
|
||||||
|
|
||||||
public interface IRobotsService{
|
public interface IRobotsService
|
||||||
|
{
|
||||||
public List<Robot> Robots { get; }
|
public List<Robot> Robots { get; }
|
||||||
|
|
||||||
public Robot CreateRobot(string name,
|
public Robot CreateRobot(string name,
|
||||||
int weight,
|
int weight,
|
||||||
int height,
|
int height,
|
||||||
string country);
|
string country);
|
||||||
|
|
||||||
public Robot? GetRobotById(int id);
|
public Robot? GetRobotById(int id);
|
||||||
|
|
||||||
public bool DeleteRobotById(int id);
|
public bool DeleteRobotById(int id);
|
||||||
|
public void ChangeRobotCountry(int robotId, string newCountry);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+10
-3
@@ -2,7 +2,7 @@ namespace RobotsWantedLeague.Services;
|
|||||||
|
|
||||||
using RobotsWantedLeague.Models;
|
using RobotsWantedLeague.Models;
|
||||||
|
|
||||||
public class NotEmptyRobotsService: IRobotsService
|
public class NotEmptyRobotsService : IRobotsService
|
||||||
{
|
{
|
||||||
private readonly IRobotsService underlyingRobotsService;
|
private readonly IRobotsService underlyingRobotsService;
|
||||||
public List<Robot> Robots { get => underlyingRobotsService.Robots; }
|
public List<Robot> Robots { get => underlyingRobotsService.Robots; }
|
||||||
@@ -24,12 +24,19 @@ public class NotEmptyRobotsService: IRobotsService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Robot? GetRobotById(int id){
|
public Robot? GetRobotById(int id)
|
||||||
|
{
|
||||||
return underlyingRobotsService.GetRobotById(id);
|
return underlyingRobotsService.GetRobotById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeleteRobotById(int id){
|
public bool DeleteRobotById(int id)
|
||||||
|
{
|
||||||
return underlyingRobotsService.DeleteRobotById(id);
|
return underlyingRobotsService.DeleteRobotById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ChangeRobotCountry(int robotId, string newCountry)
|
||||||
|
{
|
||||||
|
underlyingRobotsService.ChangeRobotCountry(robotId, newCountry);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+10
@@ -56,4 +56,14 @@ public class RobotsService: IRobotsService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ChangeRobotCountry(int robotId, string newCountry)
|
||||||
|
{
|
||||||
|
Robot robot = GetRobotById(robotId);
|
||||||
|
if (robot != null)
|
||||||
|
{
|
||||||
|
robot.VisitedCountries.Add(robot.Country);
|
||||||
|
robot.Country = newCountry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
@model Agent
|
||||||
|
|
||||||
|
@{
|
||||||
|
string imageURL = "https://good-hawk-21.deno.dev/toaster" + Model.Id.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="d-flex justify-content-center">
|
||||||
|
<div class="card mb-3" style="width: 10rem;">
|
||||||
|
<iframe class="card-img-top" src="@imageURL"></iframe>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class="table table-hover" style="width: 40%; margin-left: auto; margin-right: auto;">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<td>@Model.Id</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Nom</th>
|
||||||
|
<td>@Model.Name</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>Continent</th>
|
||||||
|
<td>@Model.Continent</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</thead>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Agent List";
|
||||||
|
}
|
||||||
|
@model List<Agent>
|
||||||
|
|
||||||
|
<h1 style="text-align: center;">LISTE DES AGENTS</h1>
|
||||||
|
|
||||||
|
<div style="margin-bottom: 20px; margin-top: 8%;">
|
||||||
|
<ul class="list-group" style="width: 20%; margin-left: auto; margin-right: auto; text-align: center;">
|
||||||
|
@foreach (Agent agent in Model){
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a href="agents/agent?id=@agent.Id">@agent.Name</a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
<form hx-post="/robots/createRobot"
|
<form hx-post="/robots/createRobot"
|
||||||
hx-ext="json-enc"
|
hx-ext="json-enc"
|
||||||
hx-trigger="submit">
|
hx-trigger="submit"
|
||||||
|
style="width: 40%; margin-left: auto; margin-right: auto;">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Le nom du robot</label>
|
<label for="name">Le nom du robot</label>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
@@ -34,8 +34,8 @@
|
|||||||
<label for="country">Pays</label>
|
<label for="country">Pays</label>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="country"
|
id="Country"
|
||||||
name="country"
|
name="Country"
|
||||||
placeholder="Suriname">
|
placeholder="Suriname">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,18 @@
|
|||||||
}
|
}
|
||||||
@model List<Robot>
|
@model List<Robot>
|
||||||
|
|
||||||
|
<h1 style="text-align: center;">LISTE DES ROBOTS RECHERCHÉS</h1>
|
||||||
|
|
||||||
<ul class="list-group">
|
<div style="margin-bottom: 20px; margin-top: 8%;">
|
||||||
|
<ul class="list-group" style="width: 20%; margin-left: auto; margin-right: auto; text-align: center;">
|
||||||
@foreach (Robot robot in Model){
|
@foreach (Robot robot in Model){
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<a href="robots/robot?id=@robot.Id">@robot.Name</a>
|
<a href="robots/robot?id=@robot.Id">@robot.Name</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
<a class="btn btn-primary mt-2" href="/robots/createRobot"> Ajouter un robot</a>
|
<a class="btn btn-primary mt-2" href="/robots/createRobot">Ajouter un robot</a>
|
||||||
|
</div>
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
}
|
}
|
||||||
<h1>@ViewData["Title"]</h1>
|
<h1>@ViewData["Title"]</h1>
|
||||||
|
|
||||||
<p>Use this page to detail your site's privacy policy.</p>
|
<p>This isn't the droids you're looking for</p>
|
||||||
@@ -1,29 +1,78 @@
|
|||||||
@model Robot
|
@model Robot
|
||||||
|
|
||||||
|
@{
|
||||||
|
string imageURL = "https://robohash.org/toaster" + Model.Id.ToString() + "?set=set2";
|
||||||
|
}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="d-flex justify-content-center">
|
<div class="d-flex justify-content-center">
|
||||||
<div class="card" style="width: 10rem;">
|
<div class="card mb-3" style="width: 10rem;">
|
||||||
<img class="card-img-top"
|
<img class="card-img-top" src="@imageURL">
|
||||||
src="https://robohash.org/aligator@Model.Id?set=set2">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<table class="table table-hover" style="width: 40%; margin-left: auto; margin-right: auto;">
|
||||||
|
|
||||||
<table class="table">
|
<thead>
|
||||||
<tr>
|
<tbody>
|
||||||
<th>Nom</th><td>@Model.Name</td>
|
<tr>
|
||||||
</tr>
|
<th>Nom</th>
|
||||||
|
<td>@Model.Name</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Poids</th><td>@Model.Weight (kg)</td>
|
<th>Poids</th>
|
||||||
</tr>
|
<td>@Model.Weight (kg)</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Taille</th><td>@Model.Height (m)</td>
|
<th>Taille</th>
|
||||||
</tr>
|
<td>@Model.Height (m)</td>
|
||||||
<tr>
|
</tr>
|
||||||
<th>Pays</th><td>@Model.Country</td>
|
<tr>
|
||||||
</tr>
|
<th>Pays</th>
|
||||||
|
<td>
|
||||||
|
<span>@Model.Country</span>
|
||||||
|
<button class="btn btn-primary ml-3" data-toggle="modal" data-target="#changeRobotCountryModal">
|
||||||
|
Modifier
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Pays visités</th>
|
||||||
|
<td>@string.Join(", ", Model.VisitedCountries)</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@Html.ValidationSummary(true)
|
||||||
|
|
||||||
|
<!-- Modal -->
|
||||||
|
<div class="modal fade" id="changeRobotCountryModal" tabindex="-1" role="dialog"
|
||||||
|
aria-labelledby="changeRobotCountryModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<form method="post" asp-action="ChangeRobotCountry" asp-route-robotId="@Model.Id">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="changeRobotCountryModalLabel">Modification du pays</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="newCountry">Entrez le nouveau pays :</label>
|
||||||
|
<input type="text" class="form-control" name="NewCountry" id="newCountry" placeholder="Italie" data-val="true">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Enregistrer</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,95 +1,109 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>@ViewData["Title"] - RobotsWantedLeague</title>
|
<title>@ViewData["Title"] - RobotsWantedLeague</title>
|
||||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||||
<link rel="stylesheet" href="~/RobotsWantedLeague.styles.css" asp-append-version="true" />
|
<link rel="stylesheet" href="~/RobotsWantedLeague.styles.css" asp-append-version="true" />
|
||||||
<script src="https://unpkg.com/htmx.org@1.9.5"`
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
|
||||||
integrity="sha384-xcuj3WpfgjlKF+FXhSQFQ0ZNr39ln+hwjN3npfM9VBnUskLolQAcN80McRIVOPuO"
|
|
||||||
crossorigin="anonymous"></script>
|
|
||||||
<script>
|
|
||||||
(function () {
|
|
||||||
function _isNumeric(str) {
|
|
||||||
if (typeof str != "string") {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return !isNaN(str) && !isNaN(parseFloat(str));
|
|
||||||
}
|
|
||||||
|
|
||||||
function _cast(str) {
|
|
||||||
return _isNumeric(str) ? parseFloat(str) : str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _addAssocToDict(obj, key, value) {
|
<script src="https://unpkg.com/htmx.org@1.9.5" `
|
||||||
let splittedKey = Array.isArray(key) ? key : key.split(".");
|
integrity="sha384-xcuj3WpfgjlKF+FXhSQFQ0ZNr39ln+hwjN3npfM9VBnUskLolQAcN80McRIVOPuO"
|
||||||
const keyToAdd = splittedKey.shift();
|
crossorigin="anonymous"></script>
|
||||||
const isTerminal = splittedKey.length === 0;
|
<script>
|
||||||
if (isTerminal) {
|
(function () {
|
||||||
obj[keyToAdd] = _cast(value);
|
function _isNumeric(str) {
|
||||||
return obj;
|
if (typeof str != "string") {
|
||||||
}
|
return false
|
||||||
if (!(keyToAdd in obj)) {
|
}
|
||||||
obj[keyToAdd] = {};
|
return !isNaN(str) && !isNaN(parseFloat(str));
|
||||||
}
|
|
||||||
return _addAssocToDict(obj[keyToAdd], splittedKey, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _createPayload(params) {
|
|
||||||
let ret = {};
|
|
||||||
for (let key of Object.keys(params)) {
|
|
||||||
_addAssocToDict(ret, key, params[key]);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
htmx.defineExtension('json-enc', {
|
|
||||||
onEvent: function (name, evt) {
|
|
||||||
if (name === "htmx:configRequest") {
|
|
||||||
evt.detail.headers['Content-Type'] = "application/json";
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
encodeParameters: function (xhr, parameters, elt) {
|
function _cast(str) {
|
||||||
xhr.overrideMimeType('text/json');
|
return _isNumeric(str) ? parseFloat(str) : str;
|
||||||
return (JSON.stringify(_createPayload(parameters)));
|
}
|
||||||
}
|
|
||||||
});
|
function _addAssocToDict(obj, key, value) {
|
||||||
})();
|
let splittedKey = Array.isArray(key) ? key : key.split(".");
|
||||||
</script>
|
const keyToAdd = splittedKey.shift();
|
||||||
|
const isTerminal = splittedKey.length === 0;
|
||||||
|
if (isTerminal) {
|
||||||
|
obj[keyToAdd] = _cast(value);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
if (!(keyToAdd in obj)) {
|
||||||
|
obj[keyToAdd] = {};
|
||||||
|
}
|
||||||
|
return _addAssocToDict(obj[keyToAdd], splittedKey, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _createPayload(params) {
|
||||||
|
let ret = {};
|
||||||
|
for (let key of Object.keys(params)) {
|
||||||
|
_addAssocToDict(ret, key, params[key]);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
htmx.defineExtension('json-enc', {
|
||||||
|
onEvent: function (name, evt) {
|
||||||
|
if (name === "htmx:configRequest") {
|
||||||
|
evt.detail.headers['Content-Type'] = "application/json";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
encodeParameters: function (xhr, parameters, elt) {
|
||||||
|
xhr.overrideMimeType('text/json');
|
||||||
|
return (JSON.stringify(_createPayload(parameters)));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="/">RobotsWantedLeague</a>
|
<a class="navbar-brand" href="/">RobotsWantedLeague</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse"
|
||||||
aria-expanded="false" aria-label="Toggle navigation">
|
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
<a class="navbar-brand" href="/agents">Agents</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse"
|
||||||
|
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</header>
|
|
||||||
<div class="container">
|
|
||||||
<main role="main" class="pb-3">
|
|
||||||
@RenderBody()
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<footer class="border-top footer text-muted">
|
|
||||||
<div class="container">
|
|
||||||
© 2023 - RobotsWantedLeague - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</div>
|
||||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
</nav>
|
||||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
</header>
|
||||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
<div class="container">
|
||||||
@await RenderSectionAsync("Scripts", required: false)
|
<main role="main" class="pb-3">
|
||||||
|
@RenderBody()
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="border-top footer text-muted">
|
||||||
|
<div class="container">
|
||||||
|
© 2023 - RobotsWantedLeague
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
@await RenderSectionAsync("Scripts", required: false)
|
||||||
|
|
||||||
|
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in new issue
Block a user