Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 4 additions & 21 deletions eShopOnWeb/eShop.MVC/Models/Infrastructure/CatalogDBInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override void Seed(CatalogDBContext context)
AddCatalogBrands(context);
AddCatalogItems(context);
AddCatalogItemPictures();

}

private void AddCatalogTypes(CatalogDBContext context)
Expand Down Expand Up @@ -174,7 +174,7 @@ IEnumerable<CatalogItem> GetCatalogItemsFromFile(CatalogDBContext context)

string[] csvheaders;
string[] requiredHeaders = { "catalogtypename", "catalogbrandname", "description", "name", "price", "pictureFileName" };
string[] optionalheaders = { "availablestock", "restockthreshold", "maxstockthreshold", "onreorder" };
string[] optionalheaders = { "availablestock", "maxstockthreshold", "onreorder" };
csvheaders = GetHeaders(csvFileCatalogItems, requiredHeaders, optionalheaders);

var catalogTypeIdLookup = context.CatalogTypes.ToDictionary(ct => ct.Type, ct => ct.Id);
Expand Down Expand Up @@ -239,23 +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)
{
Expand Down Expand Up @@ -299,7 +282,7 @@ static string[] GetHeaders(string csvfile, string[] requiredHeaders, string[] op

if (csvheaders.Count() < requiredHeaders.Count())
{
throw new Exception($"requiredHeader count '{ requiredHeaders.Count()}' is bigger then csv header count '{csvheaders.Count()}' ");
throw new Exception($"requiredHeader count '{requiredHeaders.Count()}' is bigger then csv header count '{csvheaders.Count()}' ");
}

if (optionalHeaders != null)
Expand Down Expand Up @@ -346,7 +329,7 @@ private void AddCatalogItemPictures()
{
file.Delete();
}

string zipFileCatalogItemPictures = Path.Combine(environment.ContentRootPath, "Setup", "CatalogItems.zip");
ZipFile.ExtractToDirectory(zipFileCatalogItemPictures, picturePath.ToString());
}
Expand Down
7 changes: 0 additions & 7 deletions eShopOnWeb/eShop.MVC/Views/Catalog/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.RestockThreshold, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-3">
@Html.EditorFor(model => model.RestockThreshold, new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.MaxStockThreshold, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-3">
Expand Down
8 changes: 0 additions & 8 deletions eShopOnWeb/eShop.MVC/Views/Catalog/Delete.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@
@Html.DisplayFor(model => model.AvailableStock)
</dd>

<dt>
@Html.DisplayNameFor(model => model.RestockThreshold)
</dt>

<dd>
@Html.DisplayFor(model => model.RestockThreshold)
</dd>

<dt>
@Html.DisplayNameFor(model => model.MaxStockThreshold)
</dt>
Expand Down
7 changes: 0 additions & 7 deletions eShopOnWeb/eShop.MVC/Views/Catalog/Edit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.RestockThreshold, htmlAttributes: new { @class = "control-label col-md-4" })
<div class="col-md-8">
@Html.EditorFor(model => model.RestockThreshold, new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.MaxStockThreshold, htmlAttributes: new { @class = "control-label col-md-4" })
<div class="col-md-8">
Expand Down