diff --git a/Project-Unite/Controllers/SkinsController.cs b/Project-Unite/Controllers/SkinsController.cs index a9542a3..f53963d 100644 --- a/Project-Unite/Controllers/SkinsController.cs +++ b/Project-Unite/Controllers/SkinsController.cs @@ -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; diff --git a/Project-Unite/Views/Skins/Index.cshtml b/Project-Unite/Views/Skins/Index.cshtml index ef0c495..fb2d58d 100644 --- a/Project-Unite/Views/Skins/Index.cshtml +++ b/Project-Unite/Views/Skins/Index.cshtml @@ -28,7 +28,7 @@ - @Html.ActionLink(skin.Name, "ViewSkin", "Skins", new { id = skin.Name }, null)
+ @Html.ActionLink(skin.Name, "ViewSkin", "Skins", new { id = skin.Id }, null)

By @Html.UserLink(skin.UserId) on @skin.PostedAt