Commit facfe7d2 authored by Clément's avatar Clément
Browse files

Few Details

parent 6a9bb46c
......@@ -92,12 +92,19 @@ namespace MVC.Controllers
// POST: Fight/Delete/2
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
public async Task<ActionResult> Delete(int id, FormCollection collection)
{
try
{
// TODO: Add delete logic here
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.DeleteAsync("api/fight/" + id);
}
return RedirectToAction("Index");
}
catch
......
......@@ -293,6 +293,7 @@
<Content Include="Views\War\Create.cshtml" />
<Content Include="Views\War\Delete.cshtml" />
<Content Include="Views\War\Edit.cshtml" />
<Content Include="Views\Fight\Delete.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
......
......@@ -7,10 +7,20 @@ namespace MVC.Models
{
public class FightModels
{
public int ID;
public String Name { get; set; }
public HouseModels Challenger1 { get; set; }
public HouseModels Challenger2 { get; set; }
public HouseModels Winner { get; set; }
public WarModels War { get; set; }
public FightModels()
{
ID = 0;
Name = "";
Challenger1 = null;
Challenger2 = null;
Winner = null;
War = null;
}
}
}
\ No newline at end of file
@model WebApiGOT.Models.FightDTO
@{
ViewBag.Title = "Delete";
}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>FightDTO</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Name)
</dt>
<dd>
@Html.DisplayFor(model => model.Name)
</dd>
</dl>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
<div class="form-actions no-color">
<input type="submit" value="Delete" class="btn btn-default" /> |
@Html.ActionLink("Back to List", "Index")
</div>
}
</div>
......@@ -48,7 +48,7 @@
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
@Html.ActionLink("Delete", "Delete", new { id=item.ID })
</td>
</tr>
}
......
......@@ -43,8 +43,10 @@ namespace WebApiGOT.Controllers
}
// DELETE: api/Fight/2
public void Delete(int id)
public void DeleteFight(int id)
{
BusinessLayer.ThronesTournamentManager busi = new BusinessLayer.ThronesTournamentManager();
busi.deleteFight(id);
}
}
}
......@@ -8,14 +8,25 @@ namespace WebApiGOT.Models
{
public class FightDTO
{
public int ID;
public String Name { get; set; }
public HouseDTO Challenger1 { get; set; }
public HouseDTO Challenger2 { get; set; }
public HouseDTO Winner { get; set; }
public WarDTO War { get; set; }
public FightDTO()
{
ID = 0;
Name = "";
Challenger1 = null;
Challenger2 = null;
Winner = null;
War = null ;
}
public FightDTO(Fight f)
{
ID = f.ID;
Name = f.Name;
Challenger1 = new HouseDTO(f.Challenger1);
Challenger2 = new HouseDTO(f.Challenger2);
......
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