@using WebApplication1.Repositories.ArticleCommerceRepository
@{
	Layout = null;
	var caddie = (List<ArticleCommerce>)ViewBag.Caddie;
	var stock = (List<ArticleCommerce>)ViewBag.Stock;
	var aa = (ArticleCommerce)ViewBag.ArticleAjoute;
}
<!DOCTYPE html>
<html>
<head>
	<meta name="viewport" content="width=device-width" />
	<title>Commerce</title>
	<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
	<link href="~/Content/Site.css" rel="stylesheet" />
</head>
<body>
	<div class="body-content">
		<h1>En vente :</h1>
		<table class="std">
			<tr>
				<th>&nbsp;</th>
				<th>Nom</th>
				<th>Prix U.</th>
				<th>Disponibilité</th>
			</tr>
			@foreach( var a in stock ) {
				<tr>
					<td>
						@*@Html.ActionLink( "Ajouter au caddie", "Ajouter", new { id = a.Id } )*@
						@using( Html.BeginForm( "Ajouter", "CommerceRepository" ) ) {
							<input type="hidden" name="id" value="@a.Id" />
							<input type="submit" value="+" />
						}
					</td>
					<td>@a.Nom</td>
					<td>@a.PrixVente.ToString( "0.00" )</td>
					<td>@a.Quantite</td>
				</tr>
			}
		</table>
		<hr />
		<h2>Caddie</h2>
		@foreach( var a in caddie ) {
			<p>@($"{a.Nom} - {a.PrixVente:0.00} € x {a.Quantite} = {a.PrixVente * a.Quantite:0.00} €")</p>
		}
		@*@Html.ActionLink( "Vider", "Vider" )*@
		@using( Html.BeginForm( "Vider", "CommerceRepository" ) ) {
			<input type="submit" value="Vider" />
		}
	</div>
	@if( aa != null ) {
		<script type="text/javascript">
      alert('@( Html.Raw( $"Dans le caddie : {aa.Quantite} x {aa.Nom}".Replace( "'", "\\'" ) ) )');
		</script>
	}
</body>
</html>
