diff --git a/StockManMVC/App_Start/RouteConfig.cs b/StockManMVC/App_Start/RouteConfig.cs index 3a75ebf..f0c49a2 100644 --- a/StockManMVC/App_Start/RouteConfig.cs +++ b/StockManMVC/App_Start/RouteConfig.cs @@ -18,6 +18,11 @@ namespace StockManMVC url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); + routes.MapRoute( + name: "Stocks", + url: "{controller}/{action}/{id}/{LocationID}", + defaults: new { controller = "Stocks", action = "Detail", id = UrlParameter.Optional, LocationID = UrlParameter.Optional } + ); } } } diff --git a/StockManMVC/Controllers/StocksController.cs b/StockManMVC/Controllers/StocksController.cs index 67d7bea..0836a9b 100644 --- a/StockManMVC/Controllers/StocksController.cs +++ b/StockManMVC/Controllers/StocksController.cs @@ -22,13 +22,13 @@ namespace StockManMVC.Controllers } // GET: Stocks/Details/5 - public ActionResult Details(int? id) + public ActionResult Details(int? id, string LocationID) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } - Stock stock = db.Stock.Find(id); + Stock stock = db.Stock.Find(id, LocationID); if (stock == null) { return HttpNotFound(); @@ -64,13 +64,13 @@ namespace StockManMVC.Controllers } // GET: Stocks/Edit/5 - public ActionResult Edit(int? id) + public ActionResult Edit(int? id, string LocationID) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } - Stock stock = db.Stock.Find(id); + Stock stock = db.Stock.Find(id,LocationID); if (stock == null) { return HttpNotFound(); diff --git a/StockManMVC/Models/Metadata.cs b/StockManMVC/Models/Metadata.cs new file mode 100644 index 0000000..38a348f --- /dev/null +++ b/StockManMVC/Models/Metadata.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web; + +namespace StockManMVC.Models +{ + public class ItemsMetadata + { + [StringLength(250)] + [Display(Name = "Descrizione Articolo")] + public string Descr; + + [StringLength(50)] + [Display(Name = "Famiglia Articolo")] + public string Family; + + [StringLength(250)] + [Display(Name = "Descrizione Articolo Ext")] + public string DescrExt; + + [StringLength(250)] + [Display(Name = "Cod Articolo Ext")] + public string CodExt; + + [StringLength(50)] + [Display(Name = "Cod Articolo Int")] + public string CodInt; + + } + + public class StocksMetadata + { + [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)] + [DataType(DataType.Date)] + public Nullable dtLastUpd; + } + + //public class EnrollmentMetadata + //{ + // [Range(0, 4)] + // public Nullable Grade; + //} +} \ No newline at end of file diff --git a/StockManMVC/Models/PartialClasses.cs b/StockManMVC/Models/PartialClasses.cs new file mode 100644 index 0000000..24b58f8 --- /dev/null +++ b/StockManMVC/Models/PartialClasses.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web; + +namespace StockManMVC.Models +{ + [MetadataType(typeof(ItemsMetadata))] + public partial class Items + { + } + [MetadataType(typeof(StocksMetadata))] + public partial class Stocks + { + } + + //[MetadataType(typeof(EnrollmentMetadata))] + //public partial class Enrollment + //{ + //} +} \ No newline at end of file diff --git a/StockManMVC/StockManMVC.csproj b/StockManMVC/StockManMVC.csproj index 87652c8..7eeca64 100644 --- a/StockManMVC/StockManMVC.csproj +++ b/StockManMVC/StockManMVC.csproj @@ -172,9 +172,11 @@ SMModel.tt + SMModel.tt + True True diff --git a/StockManMVC/Views/Stocks/Index.cshtml b/StockManMVC/Views/Stocks/Index.cshtml index fadbe95..9eaad7a 100644 --- a/StockManMVC/Views/Stocks/Index.cshtml +++ b/StockManMVC/Views/Stocks/Index.cshtml @@ -29,29 +29,30 @@ -@foreach (var item in Model) { - - - @Html.DisplayFor(modelItem => item.QtyConf) - - - @Html.DisplayFor(modelItem => item.Note) - - - @Html.DisplayFor(modelItem => item.dtLastUpd) - - - @Html.DisplayFor(modelItem => item.Location.Descr) - - - @Html.DisplayFor(modelItem => item.Items.Descr) - - - @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | - @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) | - @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ }) - - -} + @foreach (var item in Model) + { + + + @Html.DisplayFor(modelItem => item.QtyConf) + + + @Html.DisplayFor(modelItem => item.Note) + + + @Html.DisplayFor(modelItem => item.dtLastUpd) + + + @Html.DisplayFor(modelItem => item.Location.Descr) + + + @Html.DisplayFor(modelItem => item.Items.Descr) + + + @Html.ActionLink("Edit", "Edit", new { id = item.ItemID, LocationID = item.LocationID }) | + @Html.ActionLink("Details", "Details", new { id = item.ItemID, LocationID = item.LocationID }) | + @Html.ActionLink("Delete", "Delete", new { id = item.ItemID, LocationID = item.LocationID }) + + + } diff --git a/StockManMVC/bin/StockManMVC.dll b/StockManMVC/bin/StockManMVC.dll index 2d92521..fd9c1a5 100644 Binary files a/StockManMVC/bin/StockManMVC.dll and b/StockManMVC/bin/StockManMVC.dll differ