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

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

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