From 59cf379d56a5ff7da3bcb78ef45228a7c0e4c1a9 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 22 Mar 2016 13:22:47 +0000 Subject: [PATCH] Fixed an issue where the table didn't match the model. Fixed #67 --- PlexRequests.Core/UserMapper.cs | 8 ++++---- PlexRequests.Store/UserEntity.cs | 3 ++- PlexRequests.Store/UserRepository.cs | 4 ++-- PlexRequests.UI/Content/requests.js | 3 ++- PlexRequests.UI/Content/search.js | 6 ++++-- PlexRequests.UI/Views/Requests/Index.cshtml | 2 +- PlexRequests.UI/Views/Search/Index.cshtml | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/PlexRequests.Core/UserMapper.cs b/PlexRequests.Core/UserMapper.cs index f2f397432..c073661b4 100644 --- a/PlexRequests.Core/UserMapper.cs +++ b/PlexRequests.Core/UserMapper.cs @@ -73,7 +73,7 @@ namespace PlexRequests.Core var passwordMatch = PasswordHasher.VerifyPassword(password, u.Salt, u.Hash); if (passwordMatch) { - return new Guid(u.User); + return new Guid(u.UserGuid); } } } @@ -93,12 +93,12 @@ namespace PlexRequests.Core var repo = new UserRepository(Db); var salt = PasswordHasher.GenerateSalt(); - var userModel = new UsersModel { UserName = username, User = Guid.NewGuid().ToString(), Salt = salt, Hash = PasswordHasher.ComputeHash(password, salt)}; + var userModel = new UsersModel { UserName = username, UserGuid = Guid.NewGuid().ToString(), Salt = salt, Hash = PasswordHasher.ComputeHash(password, salt)}; repo.Insert(userModel); - var userRecord = repo.Get(userModel.User); + var userRecord = repo.Get(userModel.UserGuid); - return new Guid(userRecord.User); + return new Guid(userRecord.UserGuid); } public static bool UpdateUser(string username, string oldPassword, string newPassword) diff --git a/PlexRequests.Store/UserEntity.cs b/PlexRequests.Store/UserEntity.cs index 343794896..b3d53f8cc 100644 --- a/PlexRequests.Store/UserEntity.cs +++ b/PlexRequests.Store/UserEntity.cs @@ -32,7 +32,8 @@ namespace PlexRequests.Store { [Key] public int Id { get; set; } - public string User { get; set; } + public string UserName { get; set; } + public string UserGuid { get; set; } } } \ No newline at end of file diff --git a/PlexRequests.Store/UserRepository.cs b/PlexRequests.Store/UserRepository.cs index 47bea4ce3..3d431908e 100644 --- a/PlexRequests.Store/UserRepository.cs +++ b/PlexRequests.Store/UserRepository.cs @@ -39,7 +39,7 @@ namespace PlexRequests.Store Config = config; } - private ISqliteConfiguration Config { get; set; } + private ISqliteConfiguration Config { get; } public long Insert(T entity) { using (var cnn = Config.DbConnection()) @@ -65,7 +65,7 @@ namespace PlexRequests.Store { db.Open(); var result = db.GetAll(); - var selected = result.FirstOrDefault(x => x.User == id); + var selected = result.FirstOrDefault(x => x.UserGuid == id); return selected; } } diff --git a/PlexRequests.UI/Content/requests.js b/PlexRequests.UI/Content/requests.js index 205b471c0..1ce08c10b 100644 --- a/PlexRequests.UI/Content/requests.js +++ b/PlexRequests.UI/Content/requests.js @@ -337,7 +337,8 @@ function buildRequestContext(result, type) { issues: result.issues, otherMessage: result.otherMessage, requestId: result.id, - adminNote: result.adminNotes + adminNote: result.adminNotes, + imdb: result.imdbId }; return context; diff --git a/PlexRequests.UI/Content/search.js b/PlexRequests.UI/Content/search.js index caeaeb0a8..4e765594b 100644 --- a/PlexRequests.UI/Content/search.js +++ b/PlexRequests.UI/Content/search.js @@ -139,7 +139,8 @@ function buildMovieContext(result) { voteCount: result.voteCount, voteAverage: result.voteAverage, year: year, - type: "movie" + type: "movie", + imdb: result.imdbId }; return context; @@ -154,7 +155,8 @@ function buildTvShowContext(result) { title: result.seriesName, overview: result.overview, year: year, - type: "tv" + type: "tv", + imdb: result.imdbId }; return context; } diff --git a/PlexRequests.UI/Views/Requests/Index.cshtml b/PlexRequests.UI/Views/Requests/Index.cshtml index 5c1f38431..2b6653f0a 100644 --- a/PlexRequests.UI/Views/Requests/Index.cshtml +++ b/PlexRequests.UI/Views/Requests/Index.cshtml @@ -94,7 +94,7 @@
- +

{{title}} ({{year}})

{{status}} diff --git a/PlexRequests.UI/Views/Search/Index.cshtml b/PlexRequests.UI/Views/Search/Index.cshtml index 309435839..7e41c6b4d 100644 --- a/PlexRequests.UI/Views/Search/Index.cshtml +++ b/PlexRequests.UI/Views/Search/Index.cshtml @@ -76,7 +76,7 @@