diff --git a/eShopOnWeb/eShop.MVC/Controllers/CatalogController.cs b/eShopOnWeb/eShop.MVC/Controllers/CatalogController.cs index e68c0c1..41e29db 100644 --- a/eShopOnWeb/eShop.MVC/Controllers/CatalogController.cs +++ b/eShopOnWeb/eShop.MVC/Controllers/CatalogController.cs @@ -60,7 +60,7 @@ public IActionResult Create() // more details see https://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] - public IActionResult Create([Bind("Id", "Name", "Description", "Price", "PictureFileName", "CatalogTypeId", "CatalogBrandId", "AvailableStock", "RestockThreshold", "MaxStockThreshold", "OnReorder")] CatalogItem catalogItem) + public IActionResult Create([Bind("Id", "Name", "Description", "Price", "PictureFileName", "CatalogTypeId", "CatalogBrandId", "AvailableStock", "OnReorder")] CatalogItem catalogItem) { _log.Info($"Now processing... /Catalog/Create?catalogItemName={catalogItem.Name}"); if (ModelState.IsValid) @@ -98,7 +98,7 @@ public IActionResult Edit(int? id) // more details see https://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] - public IActionResult Edit([Bind("Id", "Name", "Description", "Price", "PictureFileName", "CatalogTypeId", "CatalogBrandId", "AvailableStock", "RestockThreshold", "MaxStockThreshold", "OnReorder")] CatalogItem catalogItem) + public IActionResult Edit([Bind("Id", "Name", "Description", "Price", "PictureFileName", "CatalogTypeId", "CatalogBrandId", "AvailableStock", "OnReorder")] CatalogItem catalogItem) { _log.Info($"Now processing... /Catalog/Edit?id={catalogItem.Id}"); if (ModelState.IsValid) diff --git a/eShopOnWeb/eShop.MVC/Models/CatalogItem.cs b/eShopOnWeb/eShop.MVC/Models/CatalogItem.cs index fcd1e6a..ebcfaf6 100644 --- a/eShopOnWeb/eShop.MVC/Models/CatalogItem.cs +++ b/eShopOnWeb/eShop.MVC/Models/CatalogItem.cs @@ -45,17 +45,9 @@ public CatalogItem() [Display(Name = "Stock")] public int AvailableStock { get; set; } - // Available stock at which we should reorder - [Display(Name = "Restock")] - public int RestockThreshold { get; set; } - - // Maximum number of units that can be in-stock at any time (due to physicial/logistical constraints in warehouses) - [Display(Name = "Max stock")] - public int MaxStockThreshold { get; set; } - /// /// True if item is on reorder /// public bool OnReorder { get; set; } } -} \ No newline at end of file +} diff --git a/eShopOnWeb/eShop.MVC/Models/Infrastructure/CatalogDBInitializer.cs b/eShopOnWeb/eShop.MVC/Models/Infrastructure/CatalogDBInitializer.cs index c3e6f17..64ac93b 100644 --- a/eShopOnWeb/eShop.MVC/Models/Infrastructure/CatalogDBInitializer.cs +++ b/eShopOnWeb/eShop.MVC/Models/Infrastructure/CatalogDBInitializer.cs @@ -174,7 +174,7 @@ IEnumerable GetCatalogItemsFromFile(CatalogDBContext context) string[] csvheaders; string[] requiredHeaders = { "catalogtypename", "catalogbrandname", "description", "name", "price", "pictureFileName" }; - string[] optionalheaders = { "availablestock", "restockthreshold", "maxstockthreshold", "onreorder" }; + string[] optionalheaders = { "availablestock", "onreorder" }; csvheaders = GetHeaders(csvFileCatalogItems, requiredHeaders, optionalheaders); var catalogTypeIdLookup = context.CatalogTypes.ToDictionary(ct => ct.Type, ct => ct.Id); @@ -239,40 +239,6 @@ static CatalogItem CreateCatalogItem(string[] column, string[] headers, Dictiona } } - int restockThresholdIndex = Array.IndexOf(headers, "restockthreshold"); - if (restockThresholdIndex != -1) - { - string restockThresholdString = column[restockThresholdIndex].Trim('"').Trim(); - if (!String.IsNullOrEmpty(restockThresholdString)) - { - if (int.TryParse(restockThresholdString, out int restockThreshold)) - { - catalogItem.RestockThreshold = restockThreshold; - } - else - { - throw new Exception($"restockThreshold={restockThreshold} is not a valid integer"); - } - } - } - - int maxStockThresholdIndex = Array.IndexOf(headers, "maxstockthreshold"); - if (maxStockThresholdIndex != -1) - { - string maxStockThresholdString = column[maxStockThresholdIndex].Trim('"').Trim(); - if (!String.IsNullOrEmpty(maxStockThresholdString)) - { - if (int.TryParse(maxStockThresholdString, out int maxStockThreshold)) - { - catalogItem.MaxStockThreshold = maxStockThreshold; - } - else - { - throw new Exception($"maxStockThreshold={maxStockThreshold} is not a valid integer"); - } - } - } - int onReorderIndex = Array.IndexOf(headers, "onreorder"); if (onReorderIndex != -1) { @@ -351,4 +317,4 @@ private void AddCatalogItemPictures() ZipFile.ExtractToDirectory(zipFileCatalogItemPictures, picturePath.ToString()); } } -} \ No newline at end of file +} diff --git a/eShopOnWeb/eShop.MVC/Services/CatalogService.cs b/eShopOnWeb/eShop.MVC/Services/CatalogService.cs index 8e9af06..e1f6c7a 100644 --- a/eShopOnWeb/eShop.MVC/Services/CatalogService.cs +++ b/eShopOnWeb/eShop.MVC/Services/CatalogService.cs @@ -72,4 +72,4 @@ public void Dispose() db.Dispose(); } } -} \ No newline at end of file +} diff --git a/eShopOnWeb/eShop.MVC/Services/CatalogServiceMock.cs b/eShopOnWeb/eShop.MVC/Services/CatalogServiceMock.cs index a814a61..98f353c 100644 --- a/eShopOnWeb/eShop.MVC/Services/CatalogServiceMock.cs +++ b/eShopOnWeb/eShop.MVC/Services/CatalogServiceMock.cs @@ -81,4 +81,4 @@ private List ComposeCatalogItems(List items) ; } } -} \ No newline at end of file +} diff --git a/eShopOnWeb/eShop.MVC/Views/Catalog/CatalogTable.cshtml b/eShopOnWeb/eShop.MVC/Views/Catalog/CatalogTable.cshtml index 622ab4e..95af280 100644 --- a/eShopOnWeb/eShop.MVC/Views/Catalog/CatalogTable.cshtml +++ b/eShopOnWeb/eShop.MVC/Views/Catalog/CatalogTable.cshtml @@ -26,12 +26,6 @@ @Html.DisplayNameFor(model => model.AvailableStock) - - @Html.DisplayNameFor(model => model.RestockThreshold) - - - @Html.DisplayNameFor(model => model.MaxStockThreshold) - @@ -63,12 +57,6 @@ @Html.DisplayFor(modelItem => item.AvailableStock) - - @Html.DisplayFor(modelItem => item.RestockThreshold) - - - @Html.DisplayFor(modelItem => item.MaxStockThreshold) - @Html.ActionLink("Edit", "Edit", new { id = item.Id }, new { @class = "esh-table-link" }) | @Html.ActionLink("Details", "Details", new { id = item.Id }, new { @class = "esh-table-link" }) | @@ -78,4 +66,4 @@ } - \ No newline at end of file + diff --git a/eShopOnWeb/eShop.MVC/Views/Catalog/Create.cshtml b/eShopOnWeb/eShop.MVC/Views/Catalog/Create.cshtml index acef5b7..6368d75 100644 --- a/eShopOnWeb/eShop.MVC/Views/Catalog/Create.cshtml +++ b/eShopOnWeb/eShop.MVC/Views/Catalog/Create.cshtml @@ -69,20 +69,6 @@ -
- @Html.LabelFor(model => model.RestockThreshold, htmlAttributes: new { @class = "control-label col-md-2" }) -
- @Html.EditorFor(model => model.RestockThreshold, new { htmlAttributes = new { @class = "form-control" } }) -
-
- -
- @Html.LabelFor(model => model.MaxStockThreshold, htmlAttributes: new { @class = "control-label col-md-2" }) -
- @Html.EditorFor(model => model.MaxStockThreshold, new { htmlAttributes = new { @class = "form-control" } }) -
-
-
@Html.ActionLink("[ Cancel ]", "Index", null, new { @class = "btn esh-button esh-button-secondary" }) diff --git a/eShopOnWeb/eShop.MVC/Views/Catalog/Details.cshtml b/eShopOnWeb/eShop.MVC/Views/Catalog/Details.cshtml index f102374..2becbe2 100644 --- a/eShopOnWeb/eShop.MVC/Views/Catalog/Details.cshtml +++ b/eShopOnWeb/eShop.MVC/Views/Catalog/Details.cshtml @@ -66,22 +66,6 @@ @Html.DisplayFor(model => model.AvailableStock) -
- @Html.DisplayNameFor(model => model.RestockThreshold) -
- -
- @Html.DisplayFor(model => model.RestockThreshold) -
- -
- @Html.DisplayNameFor(model => model.MaxStockThreshold) -
- -
- @Html.DisplayFor(model => model.MaxStockThreshold) -
-
-
- @Html.LabelFor(model => model.RestockThreshold, htmlAttributes: new { @class = "control-label col-md-4" }) -
- @Html.EditorFor(model => model.RestockThreshold, new { htmlAttributes = new { @class = "form-control" } }) -
-
- -
- @Html.LabelFor(model => model.MaxStockThreshold, htmlAttributes: new { @class = "control-label col-md-4" }) -
- @Html.EditorFor(model => model.MaxStockThreshold, new { htmlAttributes = new { @class = "form-control" } }) -
-
-
@Html.ActionLink("[ Cancel ]", "Index", null, new { @class = "btn esh-button esh-button-secondary" })