mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 11:21:47 -05:00
Fix bug with skin repo page IDs
This commit is contained in:
parent
da39089abf
commit
db70be6c4b
2 changed files with 13 additions and 3 deletions
|
@ -20,7 +20,7 @@ public ActionResult Index()
|
|||
public ActionResult ViewSkin(string id)
|
||||
{
|
||||
var db = new ApplicationDbContext();
|
||||
var skn = db.Skins.FirstOrDefault(x => x.Name == id);
|
||||
var skn = db.Skins.FirstOrDefault(x => x.Id == id);
|
||||
if (skn == null)
|
||||
return new HttpStatusCodeResult(404);
|
||||
return View(skn);
|
||||
|
@ -44,7 +44,17 @@ public ActionResult PostSkin(CreateSkinViewModel model)
|
|||
}
|
||||
var db = new ApplicationDbContext();
|
||||
var skin = new Skin();
|
||||
skin.Id = Guid.NewGuid().ToString();
|
||||
|
||||
string allowed = "abcdefghijklmnopqrstuvwxyz1234567890-_";
|
||||
|
||||
string id = model.Title.ToLower();
|
||||
foreach(char c in id.ToCharArray())
|
||||
{
|
||||
if (!allowed.Contains(c))
|
||||
id = id.Replace(c, '_');
|
||||
}
|
||||
|
||||
skin.Id = id;
|
||||
skin.Name = model.Title;
|
||||
skin.ShortDescription = model.ShortDescription;
|
||||
skin.PostedAt = DateTime.Now;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<tr>
|
||||
<td><img src="@skin.ScreenshotUrl" style="max-width:320px;width:auto;height:auto;"/></td>
|
||||
<td>
|
||||
@Html.ActionLink(skin.Name, "ViewSkin", "Skins", new { id = skin.Name }, null) <br/>
|
||||
@Html.ActionLink(skin.Name, "ViewSkin", "Skins", new { id = skin.Id }, null) <br/>
|
||||
<p>By @Html.UserLink(skin.UserId) on @skin.PostedAt</p>
|
||||
</td>
|
||||
<td>
|
||||
|
|
Loading…
Reference in a new issue