Commit 6a39a4cb authored by Clément's avatar Clément
Browse files

Few updates

parent 9777cf33
......@@ -11,6 +11,21 @@
<AssemblyName>DataAccessLayer</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PublishUrl>publier\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -51,5 +66,17 @@
<Name>EntitiesLayer</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 et x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -12,7 +12,7 @@ namespace DataAccessLayer
{
class SqlServer : DataBaseBridge
{
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=H:\\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";
......
No preview for this file type
No preview for this file type
......@@ -117,14 +117,21 @@ namespace MVC.Controllers
return View();
}
// POST: Character/Delete/5
// 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/character/" + id);
}
return RedirectToAction("Index");
}
catch
......
......@@ -34,11 +34,6 @@ namespace MVC.Controllers
return View(Houses);
}
// GET: House/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: House/Create
public ActionResult Create()
......@@ -48,56 +43,84 @@ namespace MVC.Controllers
// POST: House/Create
[HttpPost]
public ActionResult Create(FormCollection collection)
public async Task<ActionResult> Create(HouseModels collection)
{
try
{
// TODO: Add insert logic here
HouseModels house = new HouseModels();
house.Name = collection.Name;
house.NbUnits = collection.NbUnits;
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(house);
StringContent content = new StringContent(jsonString, System.Text.Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync("api/House", content);
return RedirectToAction("Index");
return RedirectToAction("Index");
}
}
catch
{
return View();
}
}
// GET: House/Edit/5
public ActionResult Edit(int id)
{
return View();
}
// POST: House/Edit/5
[HttpPost]
public ActionResult Edit(int id, FormCollection collection)
// POST: House/Edit/5
public async Task<ActionResult> Edit(int id, HouseModels collection)
{
try
{
// TODO: Add update logic here
return RedirectToAction("Index");
}
catch
HouseModels house = new HouseModels();
house.ID = id;
house.Name = collection.Name;
house.NbUnits = collection.NbUnits;
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(house);
StringContent content = new StringContent(jsonString, System.Text.Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PutAsync("api/house", content);
return RedirectToAction("Index");
}
}
// GET: House/Delete/5
// POST: House/Delete/5
public ActionResult Delete(int id)
{
return View();
}
// POST: House/Delete/5
// 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/house/" + id);
}
return RedirectToAction("Index");
}
catch
......
......@@ -287,6 +287,9 @@
<Content Include="Views\Territory\Index.cshtml" />
<Content Include="Views\Character\Delete.cshtml" />
<Content Include="Views\Character\Details.cshtml" />
<Content Include="Views\House\Create.cshtml" />
<Content Include="Views\House\Edit.cshtml" />
<Content Include="Views\House\Delete.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
......
......@@ -10,5 +10,11 @@ namespace MVC.Models
public int ID { get; set; }
public string Name { get; set; }
public int NbUnits { get; set; }
public HouseModels()
{
ID = 0;
Name = "";
NbUnits = 0;
}
}
}
\ No newline at end of file
......@@ -4,36 +4,16 @@
ViewBag.Title = "Delete";
}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
<h3>Are you sure you want to delete this character ?</h3>
<div>
<h4>CharacterModels</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.FirstName)
</dt>
<dd>
@Html.DisplayFor(model => model.FirstName)
</dd>
<dt>
@Html.DisplayNameFor(model => model.LastName)
</dt>
<dd>
@Html.DisplayFor(model => model.LastName)
</dd>
</dl>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
<div class="form-actions no-color">
<input type="submit" value="Delete" class="btn btn-default" /> |
<input type="submit" value="Delete" class="btn btn-default" />
<br><br>
@Html.ActionLink("Back to List", "Index")
</div>
}
......
@model MVC.Models.HouseModels
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>HouseModels</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NbUnits, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NbUnits, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NbUnits, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
@model MVC.Models.HouseModels
@{
ViewBag.Title = "Delete";
}
<h3>Are you sure you want to delete this house ?</h3>
<div>
<hr />
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
<div class="form-actions no-color">
<input type="submit" value="Delete" class="btn btn-default" />
<br><br>
@Html.ActionLink("Back to List", "Index")
</div>
}
</div>
@model MVC.Models.HouseModels
@{
ViewBag.Title = "Edit";
}
<h2>Edit</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>HouseModels</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.ID)
<div class="form-group">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NbUnits, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NbUnits, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NbUnits, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
......@@ -29,8 +29,8 @@
@Html.DisplayFor(modelItem => item.NbUnits)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
@Html.ActionLink("Edit", "Edit", new {id=item.ID}) |
@Html.ActionLink("Delete", "Delete", new {id=item.ID })
</td>
</tr>
}
......
......@@ -28,7 +28,7 @@
<li>@Html.ActionLink("War", "Index", "War")</li>
<li>@Html.ActionLink("Territory", "Index", "Territory")</li>
</ul>
@Html.Partial("_LoginPartial")
<!-- Html.Partial("_LoginPartial")-->
</div>
</div>
</div>
......
......@@ -29,6 +29,11 @@ namespace WebApiGOT.Controllers
Character cha = new Character(c.FirstName, c.LastName,c.Characteristics.PV,c.Characteristics.Type,c.Characteristics.Bravoury,c.Characteristics.Crazyness,new House(c.House.Name, c.House.NbUnits));
BusinessLayer.ThronesTournamentManager busi = new BusinessLayer.ThronesTournamentManager();
busi.addCharacter(cha);
}
}
public void DeleteCharacter(int id)
{
BusinessLayer.ThronesTournamentManager busi = new BusinessLayer.ThronesTournamentManager();
busi.deleteCharacater(id);
}
}
}
......@@ -6,6 +6,7 @@ using BusinessLayer;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using EntitiesLayer;
namespace WebApiGOT.Controllers
{
......@@ -25,26 +26,34 @@ namespace WebApiGOT.Controllers
}
// GET: api/House/5
public HouseDTO Get(int id)
public HouseDTO GetHouse(int id)
{
BusinessLayer.ThronesTournamentManager busi = new BusinessLayer.ThronesTournamentManager();
return new HouseDTO(busi.getHouseById(id));
HouseDTO house = new HouseDTO(busi.getHouseById(id));
return house;
}
// POST: api/House
public void Post([FromBody]string value)
public void PostAddHouse(HouseDTO house)
{
House ho = new House(house.Name, house.NbUnits);
BusinessLayer.ThronesTournamentManager busi = new BusinessLayer.ThronesTournamentManager();
busi.addHouse(ho);
}
// PUT: api/House/5
public void Put(int id, [FromBody]string value)
public void PutEditHouse(HouseDTO house)
{
House cha = new House(house.ID,house.Name, house.NbUnits);
BusinessLayer.ThronesTournamentManager busi = new BusinessLayer.ThronesTournamentManager();
busi.updateHouse(cha);
}
// DELETE: api/House/5
public void Delete(int id)
public void DeleteHouse(int id)
{
BusinessLayer.ThronesTournamentManager busi = new BusinessLayer.ThronesTournamentManager();
busi.deleteHouse(id);
}
}
}
}
\ No newline at end of file
......@@ -8,11 +8,18 @@ namespace WebApiGOT.Models
{
public class HouseDTO
{
public int ID { get; set; }
public string Name { get; set; }
public int NbUnits { get; set; }
public HouseDTO()
{
ID = 0;
Name = "";
NbUnits = 0;
}
public HouseDTO(House h)
{
ID = h.ID;
Name = h.Name;
NbUnits = h.NbUnits;
}
......
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