From 12ba997c0ed22739e2bb52cc4cd811e21b383f25 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sat, 4 Feb 2017 16:33:48 +0100 Subject: [PATCH] Fixes command since Avatar is required --- Yavsc/Controllers/CommandController.cs | 20 ++++++++++++-------- Yavsc/Models/Billing/NominatvieCommand.cs | 4 ++-- Yavsc/Views/Command/Create.cshtml | 6 ++++-- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Yavsc/Controllers/CommandController.cs b/Yavsc/Controllers/CommandController.cs index 947e1b77..3a4bfbd5 100644 --- a/Yavsc/Controllers/CommandController.cs +++ b/Yavsc/Controllers/CommandController.cs @@ -134,22 +134,26 @@ namespace Yavsc.Controllers if (string.IsNullOrWhiteSpace(uid) || string.IsNullOrWhiteSpace(prid)) throw new InvalidOperationException( - "This method needs a prid and uid" + "This method needs a PerformerId" ); var pro = _context.Performers.Include( u => u.Performer - ).Include( u => u.Performer.Devices) + ).Include(u => u.Performer.Devices) .FirstOrDefault( x => x.PerformerId == command.PerformerId ); - _logger.LogDebug($"Pro: {pro}"); - command.PerformerProfile = pro; - var user = await _userManager.FindByIdAsync( - User.GetUserId() - ); + var user = await _userManager.FindByIdAsync(uid); command.Client = user; + command.ClientId = uid; + command.PerformerProfile = pro; + // FIXME Why!! + // ModelState.ClearValidationState("PerformerProfile.Avatar"); + // ModelState.ClearValidationState("Client.Avatar"); + // ModelState.ClearValidationState("ClientId"); + ModelState.MarkFieldSkipped("ClientId"); + if (ModelState.IsValid) - { + { var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address && x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude ); diff --git a/Yavsc/Models/Billing/NominatvieCommand.cs b/Yavsc/Models/Billing/NominatvieCommand.cs index 072bca94..8c2bb031 100644 --- a/Yavsc/Models/Billing/NominatvieCommand.cs +++ b/Yavsc/Models/Billing/NominatvieCommand.cs @@ -10,13 +10,13 @@ namespace Yavsc.Models.Billing public class NominativeServiceCommand : Query where T:Service { - + [Required] public string ClientId { get; set; } /// /// The client /// - [Required,ForeignKey("ClientId")] + [ForeignKey("ClientId")] public ApplicationUser Client { get; set; } [Required] diff --git a/Yavsc/Views/Command/Create.cshtml b/Yavsc/Views/Command/Create.cshtml index c70c8a80..cdb9d8c5 100644 --- a/Yavsc/Views/Command/Create.cshtml +++ b/Yavsc/Views/Command/Create.cshtml @@ -178,7 +178,9 @@
- @Html.HiddenFor(model=>model.Location.Latitude) @Html.HiddenFor(model=>model.Location.Longitude) + +@Html.HiddenFor(model=>model.Location.Latitude) + @Html.HiddenFor(model=>model.Location.Longitude)
@@ -191,7 +193,7 @@ -@Html.HiddenFor(model=>model.Client.Id) +@Html.HiddenFor(model=>model.ClientId) @Html.HiddenFor(model=>model.PerformerId) @Html.HiddenFor(model=>model.ActivityCode)