using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;


namespace WebApplication1.Controllers {
  public class StockController : Controller {
    [HttpGet]
    public ActionResult Index() {
      lock ( Article.Stock ) {
        return View( "Index", Article.Stock.Values.ToArray() );
      }
    }
    [HttpPost]
    public ActionResult Index( Article[] nvStock ) {
      lock ( Article.Stock ) {
        foreach( var modif in nvStock ) {
          var a = Article.Stock[modif.Id];
          a.PrixAchat = modif.PrixAchat;
          a.PrixVente = modif.PrixVente;
          a.Quantite = modif.Quantite;
        }
        return View( "Index", Article.Stock.Values.ToArray() );
      }
    }

  }
}