Skip to content

Commit 18b91ee

Browse files
author
Shaun Walker
committed
minor fixes to data and UI customization
1 parent 632c023 commit 18b91ee

8 files changed

Lines changed: 83 additions & 43 deletions

File tree

src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static IEnumerable<CatalogItem> GetCatalogItemsFromFile(string contentRootPath,
190190
try
191191
{
192192
string[] requiredHeaders = { "catalogtypename", "catalogbrandname", "description", "name", "price", "pictureuri" };
193-
string[] optionalheaders = { "availablestock", "restockThreshold", "maxStockThreshold", "onreorder" };
193+
string[] optionalheaders = { "availablestock", "restockthreshold", "maxstockthreshold", "onreorder" };
194194
csvheaders = GetHeaders(csvFileCatalogItems, requiredHeaders, optionalheaders );
195195
}
196196
catch (Exception ex)
@@ -320,18 +320,18 @@ static IEnumerable<CatalogItem> GetPreconfiguredItems()
320320
{
321321
return new List<CatalogItem>()
322322
{
323-
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Bot Black Hoodie", Name = ".NET Bot Black Hoodie", Price = 19.5M, PictureUri = "1.png" },
324-
new CatalogItem() { CatalogTypeId=1,CatalogBrandId=2, Description = ".NET Black & White Mug", Name = ".NET Black & White Mug", Price= 8.50M, PictureUri = "2.png" },
325-
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Prism White T-Shirt", Name = "Prism White T-Shirt", Price = 12, PictureUri = "3.png" },
326-
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Foundation T-shirt", Name = ".NET Foundation T-shirt", Price = 12, PictureUri = "4.png" },
327-
new CatalogItem() { CatalogTypeId=3,CatalogBrandId=5, Description = "Roslyn Red Sheet", Name = "Roslyn Red Sheet", Price = 8.5M, PictureUri = "5.png" },
328-
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Blue Hoodie", Name = ".NET Blue Hoodie", Price = 12, PictureUri = "6.png" },
329-
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Roslyn Red T-Shirt", Name = "Roslyn Red T-Shirt", Price = 12, PictureUri = "7.png" },
330-
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Kudu Purple Hoodie", Name = "Kudu Purple Hoodie", Price = 8.5M, PictureUri = "8.png" },
331-
new CatalogItem() { CatalogTypeId=1,CatalogBrandId=5, Description = "Cup<T> White Mug", Name = "Cup<T> White Mug", Price = 12, PictureUri = "9.png" },
332-
new CatalogItem() { CatalogTypeId=3,CatalogBrandId=2, Description = ".NET Foundation Sheet", Name = ".NET Foundation Sheet", Price = 12, PictureUri = "10.png" },
333-
new CatalogItem() { CatalogTypeId=3,CatalogBrandId=2, Description = "Cup<T> Sheet", Name = "Cup<T> Sheet", Price = 8.5M, PictureUri = "11.png" },
334-
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Prism White TShirt", Name = "Prism White TShirt", Price = 12, PictureUri = "12.png" }
323+
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Bot Black Hoodie", Name = ".NET Bot Black Hoodie", Price = 19.5M, PictureUri = "1.png", AvailableStock = 100 },
324+
new CatalogItem() { CatalogTypeId=1,CatalogBrandId=2, Description = ".NET Black & White Mug", Name = ".NET Black & White Mug", Price= 8.50M, PictureUri = "2.png", AvailableStock = 100 },
325+
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Prism White T-Shirt", Name = "Prism White T-Shirt", Price = 12, PictureUri = "3.png", AvailableStock = 100 },
326+
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Foundation T-shirt", Name = ".NET Foundation T-shirt", Price = 12, PictureUri = "4.png", AvailableStock = 100 },
327+
new CatalogItem() { CatalogTypeId=3,CatalogBrandId=5, Description = "Roslyn Red Sheet", Name = "Roslyn Red Sheet", Price = 8.5M, PictureUri = "5.png", AvailableStock = 100 },
328+
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Blue Hoodie", Name = ".NET Blue Hoodie", Price = 12, PictureUri = "6.png", AvailableStock = 100 },
329+
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Roslyn Red T-Shirt", Name = "Roslyn Red T-Shirt", Price = 12, PictureUri = "7.png", AvailableStock = 100 },
330+
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Kudu Purple Hoodie", Name = "Kudu Purple Hoodie", Price = 8.5M, PictureUri = "8.png", AvailableStock = 100 },
331+
new CatalogItem() { CatalogTypeId=1,CatalogBrandId=5, Description = "Cup<T> White Mug", Name = "Cup<T> White Mug", Price = 12, PictureUri = "9.png", AvailableStock = 100 },
332+
new CatalogItem() { CatalogTypeId=3,CatalogBrandId=2, Description = ".NET Foundation Sheet", Name = ".NET Foundation Sheet", Price = 12, PictureUri = "10.png", AvailableStock = 100 },
333+
new CatalogItem() { CatalogTypeId=3,CatalogBrandId=2, Description = "Cup<T> Sheet", Name = "Cup<T> Sheet", Price = 8.5M, PictureUri = "11.png", AvailableStock = 100 },
334+
new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Prism White TShirt", Name = "Prism White TShirt", Price = 12, PictureUri = "12.png", AvailableStock = 100 }
335335
};
336336
}
337337

src/Services/Identity/Identity.API/Data/ApplicationContextSeed.cs

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System;
1515
using System.Collections.Generic;
1616
using System.IO;
17+
using System.IO.Compression;
1718
using System.Linq;
1819
using System.Security.Cryptography;
1920
using System.Text.RegularExpressions;
@@ -45,6 +46,7 @@ public async Task SeedAsync(IApplicationBuilder applicationBuilder, IHostingEnvi
4546

4647
var useCustomizationData = settings.UseCustomizationData;
4748
var contentRootPath = env.ContentRootPath;
49+
var webroot = env.WebRootPath;
4850

4951
if (!context.Users.Any())
5052
{
@@ -54,6 +56,11 @@ public async Task SeedAsync(IApplicationBuilder applicationBuilder, IHostingEnvi
5456

5557
await context.SaveChangesAsync();
5658
}
59+
60+
if (useCustomizationData)
61+
{
62+
GetPreconfiguredImages(contentRootPath, webroot, log);
63+
}
5764
}
5865
catch (Exception ex)
5966
{
@@ -111,34 +118,34 @@ private ApplicationUser CreateApplicationUser(string[] column, string[] headers)
111118
throw new Exception($"column count '{column.Count()}' not the same as headers count'{headers.Count()}'");
112119
}
113120

114-
string cardtypeString = column[Array.IndexOf(headers, "cardtype")].Trim();
121+
string cardtypeString = column[Array.IndexOf(headers, "cardtype")].Trim('"').Trim();
115122
if (!int.TryParse(cardtypeString, out int cardtype))
116123
{
117124
throw new Exception($"cardtype='{cardtypeString}' is not a number");
118125
}
119126

120127
var user = new ApplicationUser
121128
{
122-
CardHolderName = column[Array.IndexOf(headers, "cardholdername")].Trim(),
123-
CardNumber = column[Array.IndexOf(headers, "cardnumber")].Trim(),
129+
CardHolderName = column[Array.IndexOf(headers, "cardholdername")].Trim('"').Trim(),
130+
CardNumber = column[Array.IndexOf(headers, "cardnumber")].Trim('"').Trim(),
124131
CardType = cardtype,
125-
City = column[Array.IndexOf(headers, "city")].Trim(),
126-
Country = column[Array.IndexOf(headers, "country")].Trim(),
127-
Email = column[Array.IndexOf(headers, "email")].Trim(),
128-
Expiration = column[Array.IndexOf(headers, "expiration")].Trim(),
132+
City = column[Array.IndexOf(headers, "city")].Trim('"').Trim(),
133+
Country = column[Array.IndexOf(headers, "country")].Trim('"').Trim(),
134+
Email = column[Array.IndexOf(headers, "email")].Trim('"').Trim(),
135+
Expiration = column[Array.IndexOf(headers, "expiration")].Trim('"').Trim(),
129136
Id = Guid.NewGuid().ToString(),
130-
LastName = column[Array.IndexOf(headers, "lastname")].Trim(),
131-
Name = column[Array.IndexOf(headers, "name")].Trim(),
132-
PhoneNumber = column[Array.IndexOf(headers, "phonenumber")].Trim(),
133-
UserName = column[Array.IndexOf(headers, "username")].Trim(),
134-
ZipCode = column[Array.IndexOf(headers, "zipcode")].Trim(),
135-
State = column[Array.IndexOf(headers, "state")].Trim(),
136-
Street = column[Array.IndexOf(headers, "street")].Trim(),
137-
SecurityNumber = column[Array.IndexOf(headers, "securitynumber")].Trim(),
138-
NormalizedEmail = column[Array.IndexOf(headers, "normalizedemail")].Trim(),
139-
NormalizedUserName = column[Array.IndexOf(headers, "normalizedusername")].Trim(),
137+
LastName = column[Array.IndexOf(headers, "lastname")].Trim('"').Trim(),
138+
Name = column[Array.IndexOf(headers, "name")].Trim('"').Trim(),
139+
PhoneNumber = column[Array.IndexOf(headers, "phonenumber")].Trim('"').Trim(),
140+
UserName = column[Array.IndexOf(headers, "username")].Trim('"').Trim(),
141+
ZipCode = column[Array.IndexOf(headers, "zipcode")].Trim('"').Trim(),
142+
State = column[Array.IndexOf(headers, "state")].Trim('"').Trim(),
143+
Street = column[Array.IndexOf(headers, "street")].Trim('"').Trim(),
144+
SecurityNumber = column[Array.IndexOf(headers, "securitynumber")].Trim('"').Trim(),
145+
NormalizedEmail = column[Array.IndexOf(headers, "normalizedemail")].Trim('"').Trim(),
146+
NormalizedUserName = column[Array.IndexOf(headers, "normalizedusername")].Trim('"').Trim(),
140147
SecurityStamp = Guid.NewGuid().ToString("D"),
141-
PasswordHash = column[Array.IndexOf(headers, "password")].Trim(), // Note: This is the password
148+
PasswordHash = column[Array.IndexOf(headers, "password")].Trim('"').Trim(), // Note: This is the password
142149
};
143150

144151
user.PasswordHash = _passwordHasher.HashPassword(user, user.PasswordHash);
@@ -199,5 +206,45 @@ static string[] GetHeaders(string[] requiredHeaders, string csvfile)
199206

200207
return csvheaders;
201208
}
209+
210+
static void GetPreconfiguredImages(string contentRootPath, string webroot, ILogger log)
211+
{
212+
try
213+
{
214+
string imagesZipFile = Path.Combine(contentRootPath, "Setup", "images.zip");
215+
if (!File.Exists(imagesZipFile))
216+
{
217+
log.LogError($" zip file '{imagesZipFile}' does not exists.");
218+
return;
219+
}
220+
221+
string imagePath = Path.Combine(webroot, "images");
222+
string[] imageFiles = Directory.GetFiles(imagePath).Select(file => Path.GetFileName(file)).ToArray();
223+
224+
using (ZipArchive zip = ZipFile.Open(imagesZipFile, ZipArchiveMode.Read))
225+
{
226+
foreach (ZipArchiveEntry entry in zip.Entries)
227+
{
228+
if (imageFiles.Contains(entry.Name))
229+
{
230+
string destinationFilename = Path.Combine(imagePath, entry.Name);
231+
if (File.Exists(destinationFilename))
232+
{
233+
File.Delete(destinationFilename);
234+
}
235+
entry.ExtractToFile(destinationFilename);
236+
}
237+
else
238+
{
239+
log.LogWarning($"Skip file '{entry.Name}' in zipfile '{imagesZipFile}'");
240+
}
241+
}
242+
}
243+
}
244+
catch (Exception ex)
245+
{
246+
log.LogError($"Exception in method GetPreconfiguredImages WebMVC. Exception Message={ex.Message}");
247+
}
248+
}
202249
}
203250
}
13.9 KB
Binary file not shown.

src/Services/Identity/Identity.API/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@
4040
<br><div class="brand"></div>
4141
</div>
4242
<div class="col-sm-6">
43-
<br />
44-
<br>
45-
<br />
46-
<div class="text hidden-xs">&copy; e-ShoponContainers. All right reserved</div>
43+
<img class="text hidden-xs" src="~/images/main_footer_text.PNG" width="335" height="26" alt="footer text image" />
4744
</div>
4845
</div>
4946
</div>

src/Services/Identity/Identity.API/wwwroot/css/site.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,7 @@ footer {
476476
}
477477

478478
footer .text {
479-
text-align: right;
480-
width: 100%;
481-
height: 100%;
482-
color: #83D01B;
483-
margin-top: 10px;
479+
margin-top: 55px;
484480
}
485481

486482
.text {

0 commit comments

Comments
 (0)