Commit 998415b4 authored by NEBOIT Jean-Charles's avatar NEBOIT Jean-Charles
Browse files

Update

parent 566f2418
......@@ -12,9 +12,9 @@ namespace DataAccessLayer
{
class SqlServer : DataBaseBridge
{
//private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=H:\\Documents\\ThronesTournamentConsole\\Database\\db.mdf;Integrated Security=True;Connect Timeout=30";
private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=H:\\Documents\\ServiceWeb\\Database\\db.mdf;Integrated Security=True;Connect Timeout=30";
//private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Users\\NEBOIT\\Documents\\GitHub\\ServiceWeb\\Database\\db.mdf;Integrated Security=True;Connect Timeout=30";
private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\JULES\\DOCUMENTS\\ISIMA\\2ÈME ANNÉE\\SERVICEWEB\\DATABASE\\DB.MDF;Integrated Security=True;Connect Timeout=30";
//private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\JULES\\DOCUMENTS\\ISIMA\\2ÈME ANNÉE\\SERVICEWEB\\DATABASE\\DB.MDF;Integrated Security=True;Connect Timeout=30";
private void LogException(Exception e)
{
......
No preview for this file type
No preview for this file type
......@@ -58,7 +58,8 @@ namespace MVC.Controllers
}
ViewBag.ListHouses = houses.Select(h => new SelectListItem()
{
Text = h.Name
Text = h.Name,
Value = h.ID.ToString()
});
return View();
}
......@@ -66,52 +67,26 @@ namespace MVC.Controllers
// POST: Character/Create
[HttpPost]
public async Task<ActionResult> Create(CharacterModels collection)
{
try
{
/*IEnumerable<CharacterModels> Characters = new List<CharacterModels>();
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:13666/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync("api/character");
if (response.IsSuccessStatusCode)
{
string temp = await response.Content.ReadAsStringAsync();
Characters = JsonConvert.DeserializeObject<List<CharacterModels>>(temp);
}
}*/
CharacterModels perso = new CharacterModels();
//perso._id = collection._id;
perso.House=collection.House;
perso.FirstName = collection.FirstName;
perso.LastName = collection.LastName;
perso.Characteristics.PV = collection.Characteristics.PV;
perso.Characteristics.Bravoury = collection.Characteristics.Bravoury;
perso.Characteristics.Crazyness = collection.Characteristics.Crazyness;
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:13666/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
String jsonString = JsonConvert.SerializeObject(perso);
StringContent content = new StringContent(jsonString, System.Text.Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync("api/character", content);
return View();
}
}
catch
{
CharacterModels perso = new CharacterModels();
//perso._id = collection._id;
perso.House=collection.House;
perso.FirstName = collection.FirstName;
perso.LastName = collection.LastName;
perso.Characteristics.PV = collection.Characteristics.PV;
perso.Characteristics.Bravoury = collection.Characteristics.Bravoury;
perso.Characteristics.Crazyness = collection.Characteristics.Crazyness;
using (var client = new HttpClient())
{
return View();
client.BaseAddress = new Uri("http://localhost:13666/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
String jsonString = JsonConvert.SerializeObject(perso);
StringContent content = new StringContent(jsonString, System.Text.Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync("api/character", content);
}
return View();
}
// GET: Character/Edit/5
......
......@@ -41,6 +41,7 @@ namespace MVC.Models
public class CharacterModels
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public HouseModels House { get; set; }
......@@ -49,13 +50,12 @@ namespace MVC.Models
public CharacterModels()
{
ID = 0;
FirstName = "";
LastName = "";
House = null;
Characteristics = null;
RelationShips = null;
}
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ namespace MVC.Models
{
public class HouseModels
{
public int ID { get; set; }
public string Name { get; set; }
public int NbUnits { get; set; }
}
......
......@@ -17,7 +17,7 @@
<div class="form-group">
@Html.LabelFor(model => model.FirstName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.FirstName, new { htmlAttributes = new { @class = "form-control" } })
@Html.TextBoxFor(model => model.FirstName, new { @type = "text", @class = "form-control" })
@Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" })
</div>
</div>
......@@ -25,14 +25,43 @@
<div class="form-group">
@Html.LabelFor(model => model.LastName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.LastName, new { htmlAttributes = new { @class = "form-control" } })
@Html.TextBoxFor(model => model.LastName, new { @type = "text", @class = "form-control" })
@Html.ValidationMessageFor(model => model.LastName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.House, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("ListHouses")
@Html.DropDownListFor(model => model.House.ID, ViewBag.ListHouses as IEnumerable<SelectListItem>, "", new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.House, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Characteristics.PV, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.Characteristics.PV, new { @type = "number", @class = "form-control" })
@Html.ValidationMessageFor(model => model.Characteristics.PV, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Characteristics.Type, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EnumDropDownListFor(model => model.Characteristics.Type, "", new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Characteristics.Type, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Characteristics.Bravoury, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.Characteristics.Bravoury, new { @type = "number", @class = "form-control" })
@Html.ValidationMessageFor(model => model.Characteristics.Bravoury, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Characteristics.Crazyness, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.Characteristics.Crazyness, new { @type = "number", @class = "form-control" })
@Html.ValidationMessageFor(model => model.Characteristics.Crazyness, "", new { @class = "text-danger" })
</div>
</div>
......
......@@ -53,9 +53,9 @@
}
</td> -->
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
@Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
</td>
</tr>
}
......
......@@ -24,6 +24,7 @@ namespace WebApiGOT.Models
public class CharacterDTO
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public HouseDTO House { get; set; }
......@@ -32,6 +33,7 @@ namespace WebApiGOT.Models
public CharacterDTO(Character c)
{
ID = c.ID;
FirstName = c.FirstName;
LastName = c.LastName;
House = new HouseDTO(c.House);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment