Commit d6032de9 authored by julescournut's avatar julescournut
Browse files

Add Fight List

parent 9dc365e3
......@@ -13,7 +13,8 @@ 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=C:\\Users\\NEBOIT\\Documents\\GitHub\\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 void LogException(Exception e)
{
......
using System;
using System.Net;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC.Models;
using System.Net.Http;
using Newtonsoft.Json;
using System.Threading.Tasks;
namespace MVC.Controllers
{
public class FightController : Controller
{
// GET: Fight
public async Task<ActionResult> Index()
{
IEnumerable<FightModels> Fights = new List<FightModels>();
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/Fight");
if (response.IsSuccessStatusCode)
{
string temp = await response.Content.ReadAsStringAsync();
Fights = JsonConvert.DeserializeObject<List<FightModels>>(temp);
}
}
return View(Fights);
}
// GET: Fght/Details/1
public ActionResult Details(int id)
{
return View();
}
// GET: Fght/Create
public ActionResult Create()
{
return View();
}
// POST: Fights/Create
[HttpPost]
public ActionResult Create(FormCollection collection)
{
try
{
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
// GET: Fight/Edit/1
public ActionResult Edit(int id)
{
return View();
}
// POST: Fight/Edit/1
[HttpPost]
public ActionResult Edit(int id, FormCollection collection)
{
try
{
// TODO: Add update logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
// GET: Fight/Delete/1
public ActionResult Delete(int id)
{
return View();
}
// POST: Fight/Delete/2
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
try
{
// TODO: Add delete logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
}
}
using System;
using System.Net;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC.Models;
using System.Net.Http;
using Newtonsoft.Json;
using System.Threading.Tasks;
namespace MVC.Controllers
{
public class TerritoryController : Controller
{
// GET: Territory
public async Task<ActionResult> Index()
{
IEnumerable<TerritoryModels> Territorys = new List<TerritoryModels>();
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/Territory");
if (response.IsSuccessStatusCode)
{
string temp = await response.Content.ReadAsStringAsync();
Territorys = JsonConvert.DeserializeObject<List<TerritoryModels>>(temp);
}
}
return View(Territorys);
}
// GET: Territory/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: Territory/Create
public ActionResult Create()
{
return View();
}
// POST: Territory/Create
[HttpPost]
public ActionResult Create(FormCollection collection)
{
try
{
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
// GET: Territory/Edit/5
public ActionResult Edit(int id)
{
return View();
}
// POST: Territory/Edit/5
[HttpPost]
public ActionResult Edit(int id, FormCollection collection)
{
try
{
// TODO: Add update logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
// GET: Territory/Delete/5
public ActionResult Delete(int id)
{
return View();
}
// POST: Territory/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
try
{
// TODO: Add delete logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
}
}
using System;
using System.Net;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC.Models;
using System.Net.Http;
using Newtonsoft.Json;
using System.Threading.Tasks;
namespace MVC.Controllers
{
public class WarController : Controller
{
// GET: War
public async Task<ActionResult> Index()
{
IEnumerable<WarModels> Wars = new List<WarModels>();
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/War");
if (response.IsSuccessStatusCode)
{
string temp = await response.Content.ReadAsStringAsync();
Wars = JsonConvert.DeserializeObject<List<WarModels>>(temp);
}
}
return View(Wars);
}
// GET: War/Details/0
public ActionResult Details(int id)
{
return View();
}
// GET: War/Create
public ActionResult Create()
{
return View();
}
// POST: War/Create
[HttpPost]
public ActionResult Create(FormCollection collection)
{
try
{
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
// GET: War/Edit/1
public ActionResult Edit(int id)
{
return View();
}
// POST: War/Edit/1
[HttpPost]
public ActionResult Edit(int id, FormCollection collection)
{
try
{
// TODO: Add update logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
// GET: War/Delete/1
public ActionResult Delete(int id)
{
return View();
}
// POST: War/Delete/1
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
try
{
// TODO: Add delete logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
}
}
......@@ -26,6 +26,7 @@
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -194,6 +195,9 @@
<Compile Include="App_Start\Startup.Auth.cs" />
<Compile Include="Controllers\AccountController.cs" />
<Compile Include="Controllers\CharacterController.cs" />
<Compile Include="Controllers\TerritoryController.cs" />
<Compile Include="Controllers\WarController.cs" />
<Compile Include="Controllers\FightController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\HouseController.cs" />
<Compile Include="Controllers\ManageController.cs" />
......@@ -202,6 +206,9 @@
</Compile>
<Compile Include="Models\AccountViewModels.cs" />
<Compile Include="Models\CharacterModels.cs" />
<Compile Include="Models\TerritoryModels.cs" />
<Compile Include="Models\WarModels.cs" />
<Compile Include="Models\FightModels.cs" />
<Compile Include="Models\HouseModels.cs" />
<Compile Include="Models\IdentityModels.cs" />
<Compile Include="Models\ManageViewModels.cs" />
......@@ -274,6 +281,7 @@
<Content Include="Views\Character\Index.cshtml" />
<Content Include="Views\Character\Create.cshtml" />
<Content Include="Views\House\Index.cshtml" />
<Content Include="Views\Fight\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MVC.Models
{
public class FightModels
{
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; }
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MVC.Models
{
public enum TerritoryType
{
SEA,
MOUNTAIN,
LAND,
DESERT
}
public class TerritoryModels
{
public TerritoryType Type { get; set; }
public HouseModels Owner { get; set; }
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MVC.Models
{
public class WarModels
{
public String Name { get; set; }
}
}
\ No newline at end of file
@model IEnumerable<MVC.Models.FightModels>
@{
ViewBag.Title = "All Fights";
}
<h2>@ViewBag.Title</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Challenger1)
</th>
<th>
@Html.DisplayNameFor(model => model.Challenger2)
</th>
<th>
@Html.DisplayNameFor(model => model.Winner)
</th>
<th>
@Html.DisplayNameFor(model => model.War)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Challenger1.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Challenger2.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Winner.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.War.Name)
</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 */ })
</td>
</tr>
}
</table>
......@@ -23,6 +23,9 @@
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Accueil", "Index", "Home")</li>
<li>@Html.ActionLink("Character", "Index", "Character")</li>
<li>@Html.ActionLink("House", "Index", "House")</li>
<li>@Html.ActionLink("Fight", "Index", "Fight")</li>
<li>@Html.ActionLink("À propos de", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.Linq;
using WebApiGOT.Models;
using BusinessLayer;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace WebApiGOT.Controllers
{
public class FightController : ApiController
{
// GET: api/Fight
public List<FightDTO> GetAllFight()
{
List<FightDTO> list = new List<FightDTO>();
BusinessLayer.ThronesTournamentManager busi = new BusinessLayer.ThronesTournamentManager();
foreach (EntitiesLayer.Fight fight in busi.FightsList())
{
list.Add(new FightDTO(fight));
}
return list;
}
// GET: api/Fight/2
public FightDTO Get(int id)
{
BusinessLayer.ThronesTournamentManager busi = new BusinessLayer.ThronesTournamentManager();
return new FightDTO(busi.getFightById(id));
}
// POST: api/Fight
public void Post([FromBody]string value)
{
}
// PUT: api/Fight/2
public void Put(int id, [FromBody]string value)
{
}
// DELETE: api/Fight/2
public void Delete(int id)
{
}
}
}
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