fixe le retour après connection pour prise de rendez-vous

main
Paul Schneider 9 years ago
parent 9bb246e4c0
commit 57a6ecb654
3 changed files with 23 additions and 21 deletions

@ -24,7 +24,7 @@ namespace Yavsc.Controllers
public class HairCutCommandController : CommandController public class HairCutCommandController : CommandController
{ {
public HairCutCommandController(ApplicationDbContext context, public HairCutCommandController(ApplicationDbContext context,
IOptions<GoogleAuthSettings> googleSettings, IOptions<GoogleAuthSettings> googleSettings,
IGoogleCloudMessageSender GCMSender, IGoogleCloudMessageSender GCMSender,
UserManager<ApplicationUser> userManager, UserManager<ApplicationUser> userManager,
@ -35,15 +35,13 @@ namespace Yavsc.Controllers
ILoggerFactory loggerFactory) : base(context,googleSettings,GCMSender,userManager, ILoggerFactory loggerFactory) : base(context,googleSettings,GCMSender,userManager,
localizer,emailSender,smtpSettings,siteSettings,loggerFactory) localizer,emailSender,smtpSettings,siteSettings,loggerFactory)
{ {
} }
[HttpPost, Authorize] [HttpPost, Authorize]
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
public async Task<IActionResult> CreateHairCutQuery(HairCutQuery command) public async Task<IActionResult> CreateHairCutQuery(HairCutQuery command)
{ {
var uid = User.GetUserId(); var uid = User.GetUserId();
var prid = command.PerformerId; var prid = command.PerformerId;
if (string.IsNullOrWhiteSpace(uid) if (string.IsNullOrWhiteSpace(uid)
@ -66,10 +64,10 @@ namespace Yavsc.Controllers
// ModelState.ClearValidationState("Client.Avatar"); // ModelState.ClearValidationState("Client.Avatar");
// ModelState.ClearValidationState("ClientId"); // ModelState.ClearValidationState("ClientId");
ModelState.MarkFieldSkipped("ClientId"); ModelState.MarkFieldSkipped("ClientId");
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address
&& x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude ); && x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude );
if (existingLocation!=null) { if (existingLocation!=null) {
@ -112,10 +110,9 @@ namespace Yavsc.Controllers
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode); ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode);
ViewBag.GoogleSettings = _googleSettings; ViewBag.GoogleSettings = _googleSettings;
return View(command); return View(command);
} }
[ValidateAntiForgeryToken]
public ActionResult HairCut(string performerId, string activityCode) public ActionResult HairCut(string performerId, string activityCode)
{ {
HairPrestation pPrestation=null; HairPrestation pPrestation=null;
@ -124,14 +121,14 @@ namespace Yavsc.Controllers
pPrestation = JsonConvert.DeserializeObject<HairPrestation>(prestaJson); pPrestation = JsonConvert.DeserializeObject<HairPrestation>(prestaJson);
} }
else pPrestation = new HairPrestation {}; else pPrestation = new HairPrestation {};
ViewBag.HairTaints = _context.HairTaint.Include(t=>t.Color); ViewBag.HairTaints = _context.HairTaint.Include(t=>t.Color);
ViewBag.HairTechnos = EnumExtensions.GetSelectList(typeof(HairTechnos),_localizer); ViewBag.HairTechnos = EnumExtensions.GetSelectList(typeof(HairTechnos),_localizer);
ViewBag.HairLength = EnumExtensions.GetSelectList(typeof(HairLength),_localizer); ViewBag.HairLength = EnumExtensions.GetSelectList(typeof(HairLength),_localizer);
ViewBag.Activity = _context.Activities.First(a => a.Code == activityCode); ViewBag.Activity = _context.Activities.First(a => a.Code == activityCode);
ViewBag.Gender = EnumExtensions.GetSelectList(typeof(HairCutGenders),_localizer); ViewBag.Gender = EnumExtensions.GetSelectList(typeof(HairCutGenders),_localizer);
ViewBag.HairDressings = EnumExtensions.GetSelectList(typeof(HairDressings),_localizer); ViewBag.HairDressings = EnumExtensions.GetSelectList(typeof(HairDressings),_localizer);
ViewBag.ColorsClass = ( pPrestation.Tech == HairTechnos.Color ViewBag.ColorsClass = ( pPrestation.Tech == HairTechnos.Color
|| pPrestation.Tech == HairTechnos.Mech ) ? "":"hidden"; || pPrestation.Tech == HairTechnos.Mech ) ? "":"hidden";
ViewBag.TechClass = ( pPrestation.Gender == HairCutGenders.Women ) ? "":"hidden"; ViewBag.TechClass = ( pPrestation.Gender == HairCutGenders.Women ) ? "":"hidden";
ViewData["PerfPrefs"] = _context.BrusherProfile.Single(p=>p.UserId == performerId); ViewData["PerfPrefs"] = _context.BrusherProfile.Single(p=>p.UserId == performerId);
@ -151,7 +148,7 @@ namespace Yavsc.Controllers
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
public async Task<IActionResult> CreateHairMultiCutQuery(HairMultiCutQuery command) public async Task<IActionResult> CreateHairMultiCutQuery(HairMultiCutQuery command)
{ {
var uid = User.GetUserId(); var uid = User.GetUserId();
var prid = command.PerformerId; var prid = command.PerformerId;
if (string.IsNullOrWhiteSpace(uid) if (string.IsNullOrWhiteSpace(uid)
@ -174,10 +171,10 @@ namespace Yavsc.Controllers
// ModelState.ClearValidationState("Client.Avatar"); // ModelState.ClearValidationState("Client.Avatar");
// ModelState.ClearValidationState("ClientId"); // ModelState.ClearValidationState("ClientId");
ModelState.MarkFieldSkipped("ClientId"); ModelState.MarkFieldSkipped("ClientId");
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address
&& x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude ); && x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude );
if (existingLocation!=null) { if (existingLocation!=null) {
@ -222,4 +219,4 @@ namespace Yavsc.Controllers
return View(command); return View(command);
} }
} }
} }

@ -8,11 +8,13 @@
@foreach (var profile in Model) { @foreach (var profile in Model) {
<hr/> <hr/>
@Html.DisplayFor(m=>profile) @Html.DisplayFor(m=>profile)
<form asp-controller="HairCutCommand" asp-action="HairCut"> <a asp-controller="HairCutCommand" asp-action="HairCut"
<input type="hidden" name="performerId" value="@profile.PerformerId" /> asp-route-activityCode="@ViewBag.Activity.Code"
<input type="hidden" name="activityCode" value="@ViewBag.Activity.Code" /> asp-route-performerId="@profile.Performer.Id"
<input type="submit" value="@SR["Proposer un rendez-vous à"] @profile.Performer.UserName"/> class="btn btn-link">
</form> @SR["Proposer un rendez-vous à"] @profile.Performer.UserName
</a>
} }

@ -32,5 +32,8 @@
<Content Include="Models\Haircut\HairCutGenders.cs" /> <Content Include="Models\Haircut\HairCutGenders.cs" />
<Content Include="Models\Haircut\HairTechnos.cs" /> <Content Include="Models\Haircut\HairTechnos.cs" />
<Content Include="Models\Haircut\HairTaint.cs" /> <Content Include="Models\Haircut\HairTaint.cs" />
<Content Include="Controllers\HairCutCommandController.cs" />
<Content Include="Views\FrontOffice\HairCut.cshtml" />
<Content Include="Controllers\FrontOfficeController.cs" />
</ItemGroup> </ItemGroup>
</Project> </Project>
Loading…