Implements Full name setup
This commit is contained in:
@ -93,6 +93,7 @@ namespace Yavsc.Controllers
|
||||
: message == ManageMessageId.SetBankInfoSuccess ? _SR["Vos informations bancaires ont bien été enregistrées."]
|
||||
: message == ManageMessageId.SetAddressSuccess ? _SR["Votre adresse a bien été enregistrée."]
|
||||
: message == ManageMessageId.SetMonthlyEmailSuccess ? _SR["Vos préférences concernant la lettre mensuelle ont été sauvegardées."]
|
||||
: message == ManageMessageId.SetFullNameSuccess ? _SR["Votre nom complet a été renseigné."]
|
||||
: "";
|
||||
|
||||
var user = await GetCurrentUserAsync();
|
||||
@ -120,7 +121,8 @@ namespace Yavsc.Controllers
|
||||
DedicatedCalendarId = user.DedicatedGoogleCalendar,
|
||||
EMail = user.Email,
|
||||
EmailConfirmed = await _userManager.IsEmailConfirmedAsync(user),
|
||||
AllowMonthlyEmail = user.AllowMonthlyEmail
|
||||
AllowMonthlyEmail = user.AllowMonthlyEmail,
|
||||
Address = user.PostalAddress.Address
|
||||
};
|
||||
model.HaveProfessionalSettings = _dbContext.Performers.Any(x => x.PerformerId == user.Id);
|
||||
var usrActs = _dbContext.UserActivities.Include(a=>a.Does).Where(a=> a.UserId == user.Id).ToArray();
|
||||
@ -354,8 +356,22 @@ namespace Yavsc.Controllers
|
||||
public async Task<IActionResult> SetFullName()
|
||||
{
|
||||
var user = await _userManager.FindByIdAsync(User.GetUserId());
|
||||
return View(user);
|
||||
return View(new SetFullNameViewModel { FullName = user.FullName });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> SetFullName(SetFullNameViewModel model)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var user = await _userManager.FindByIdAsync(User.GetUserId());
|
||||
user.FullName = model.FullName;
|
||||
await _userManager.UpdateAsync(user);
|
||||
return RedirectToAction(nameof(Index), new { Message = ManageMessageId.SetFullNameSuccess });
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
||||
//
|
||||
// POST: /Manage/ChangePassword
|
||||
[HttpPost]
|
||||
@ -688,13 +704,14 @@ namespace Yavsc.Controllers
|
||||
SetBankInfoSuccess,
|
||||
SetAddressSuccess,
|
||||
SetMonthlyEmailSuccess,
|
||||
SetFullNameSuccess,
|
||||
Error
|
||||
}
|
||||
|
||||
|
||||
private async Task<ApplicationUser> GetCurrentUserAsync()
|
||||
{
|
||||
return await _userManager.FindByIdAsync(HttpContext.User.GetUserId());
|
||||
return await _dbContext.Users.Include(u => u.PostalAddress).FirstOrDefaultAsync(u => u.Id == User.GetUserId());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -10,7 +10,8 @@ namespace Yavsc.ViewModels.Manage
|
||||
{
|
||||
public string UserName {get; set; }
|
||||
|
||||
public string Avatar { get; set; }
|
||||
public string Avatar { get; set; }
|
||||
public string Address { get; set; }
|
||||
|
||||
public bool HasPassword { get; set; }
|
||||
|
||||
|
13
src/Yavsc/ViewModels/Manage/SetFullNameViewModel.cs
Normal file
13
src/Yavsc/ViewModels/Manage/SetFullNameViewModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Yavsc.Attributes.Validation;
|
||||
|
||||
namespace Yavsc.ViewModels.Manage
|
||||
{
|
||||
public class SetFullNameViewModel
|
||||
{
|
||||
[Required]
|
||||
[Display(Name = "Your full name"), YaStringLength(512)]
|
||||
public string FullName { get; set; }
|
||||
}
|
||||
}
|
@ -34,13 +34,21 @@
|
||||
</dd>
|
||||
|
||||
<dd>
|
||||
<dt>@SR["AllowMonthlyEmail"]:</dt>
|
||||
<dl>
|
||||
<a asp-action="ProfileEMailUsage"> @Html.DisplayFor(m=>m.AllowMonthlyEmail) [modifier]
|
||||
</a>
|
||||
<dt>@SR["AllowMonthlyEmail"]:</dt>
|
||||
<dd>
|
||||
<a asp-action="ProfileEMailUsage"> @Html.DisplayFor(m=>m.AllowMonthlyEmail) [modifier]
|
||||
</a>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
|
||||
|
||||
<dt>@SR["FullName"]:</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(m=>m.FullName) <a asp-action="SetFullName">[modifier]</a>
|
||||
</dd>
|
||||
|
||||
@if (Model.Roles.Count()>0) {
|
||||
<dt>@SR["Roles"]:</dt>
|
||||
<dd>
|
||||
|
22
src/Yavsc/Views/Manage/SetFullName.cshtml
Normal file
22
src/Yavsc/Views/Manage/SetFullName.cshtml
Normal file
@ -0,0 +1,22 @@
|
||||
@model SetFullNameViewModel
|
||||
|
||||
@{ ViewData["Title"] = SR["Your full name"]; }
|
||||
|
||||
<h2>@ViewData["Title"]</h2>
|
||||
|
||||
<form asp-controller="Manage" asp-action="SetFullName" method="post" class="form-horizontal" role="form">
|
||||
<h4>@SR["Indicate below your full name"]:</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.All" class="text-danger" id="valsum"></div>
|
||||
|
||||
<div class="form-group">
|
||||
<label asp-for="FullName" class="col-md-2 control-label">
|
||||
@SR["Your full name"]
|
||||
</label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="FullName" class="form-control" />
|
||||
<span asp-validation-for="FullName" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="form-control btn btn-default">@SR["Validate"]</button>
|
||||
</form>
|
Reference in New Issue
Block a user