From 8350d0bddfd5db77c441e6fbf33ab5443e46853d Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Sun, 7 Feb 2021 16:37:47 -0500 Subject: [PATCH] Add real name to profile form (#12) --- .../Client/Pages/Citizen/EditProfile.razor | 10 ++++++++++ .../Client/Pages/Citizen/EditProfile.razor.cs | 1 + src/JobsJobsJobs/Client/Shared/SkillEdit.razor | 4 ++-- src/JobsJobsJobs/Client/wwwroot/css/app.css | 3 ++- .../Server/Areas/Api/Controllers/ProfileController.cs | 6 +++++- src/JobsJobsJobs/Shared/Api/ProfileForm.cs | 6 ++++++ 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor index 18eff4e..4296381 100644 --- a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor +++ b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor @@ -11,6 +11,16 @@ +
+
+
+ + + ProfileForm.RealName) /> +
+
+
diff --git a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs index 73632db..dec8acc 100644 --- a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs +++ b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs @@ -48,6 +48,7 @@ namespace JobsJobsJobs.Client.Pages.Citizen ServerApi.SetJwt(http, state); var continentTask = state.GetContinents(http); var profileTask = ServerApi.RetrieveProfile(http, state); + //var citizenTask = ServerApi.RetrieveOne(http,) await Task.WhenAll(continentTask, profileTask); diff --git a/src/JobsJobsJobs/Client/Shared/SkillEdit.razor b/src/JobsJobsJobs/Client/Shared/SkillEdit.razor index b834709..5dcef53 100644 --- a/src/JobsJobsJobs/Client/Shared/SkillEdit.razor +++ b/src/JobsJobsJobs/Client/Shared/SkillEdit.razor @@ -5,7 +5,7 @@
- + @@ -13,7 +13,7 @@
- + diff --git a/src/JobsJobsJobs/Client/wwwroot/css/app.css b/src/JobsJobsJobs/Client/wwwroot/css/app.css index 3a4c3f1..fe44608 100644 --- a/src/JobsJobsJobs/Client/wwwroot/css/app.css +++ b/src/JobsJobsJobs/Client/wwwroot/css/app.css @@ -66,6 +66,7 @@ label.jjj-required::after { content: ' *'; } -label.jjj-label { +label.jjj-label, +::placeholder { font-style: italic; } diff --git a/src/JobsJobsJobs/Server/Areas/Api/Controllers/ProfileController.cs b/src/JobsJobsJobs/Server/Areas/Api/Controllers/ProfileController.cs index ad9cc53..534a18a 100644 --- a/src/JobsJobsJobs/Server/Areas/Api/Controllers/ProfileController.cs +++ b/src/JobsJobsJobs/Server/Areas/Api/Controllers/ProfileController.cs @@ -46,7 +46,7 @@ namespace JobsJobsJobs.Server.Areas.Api.Controllers private CitizenId CurrentCitizenId => CitizenId.Parse(User.FindFirst(ClaimTypes.NameIdentifier)!.Value); // This returns 204 to indicate that there is no profile data for the current citizen (if, of course, that is - // the case. The version where an ID is specified returns 404, which is an error condition, as it should not + // the case). The version where an ID is specified returns 404, which is an error condition, as it should not // occur unless someone is messing with a URL. [HttpGet("")] public async Task Get() @@ -89,6 +89,10 @@ namespace JobsJobsJobs.Server.Areas.Api.Controllers foreach (var skill in skills) await _db.SaveSkill(skill); await _db.DeleteMissingSkills(CurrentCitizenId, skills.Select(s => s.Id)); + // Real Name + _db.Update((await _db.FindCitizenById(CurrentCitizenId))! + with { RealName = string.IsNullOrWhiteSpace(form.RealName) ? null : form.RealName }); + await _db.SaveChangesAsync(); return Ok(); } diff --git a/src/JobsJobsJobs/Shared/Api/ProfileForm.cs b/src/JobsJobsJobs/Shared/Api/ProfileForm.cs index 2af49e3..12788a3 100644 --- a/src/JobsJobsJobs/Shared/Api/ProfileForm.cs +++ b/src/JobsJobsJobs/Shared/Api/ProfileForm.cs @@ -19,6 +19,12 @@ namespace JobsJobsJobs.Shared.Api /// public bool IsPublic { get; set; } + /// + /// The user's real name + /// + [StringLength(255)] + public string RealName { get; set; } = ""; + /// /// The ID of the continent on which the citizen is located ///