Fixes command since Avatar is required

This commit is contained in:
2017-02-04 16:33:48 +01:00
parent 21ec2f40b3
commit 12ba997c0e
3 changed files with 18 additions and 12 deletions

View File

@ -134,7 +134,7 @@ 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
@ -142,12 +142,16 @@ namespace Yavsc.Controllers
.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

View File

@ -10,13 +10,13 @@ namespace Yavsc.Models.Billing
public class NominativeServiceCommand<T> : Query<T> where T:Service
{
[Required]
public string ClientId { get; set; }
/// <summary>
/// The client
/// </summary>
[Required,ForeignKey("ClientId")]
[ForeignKey("ClientId")]
public ApplicationUser Client { get; set; }
[Required]

View File

@ -178,7 +178,9 @@
<div class='col-sm-6'>
<div id='reason1'>
<textarea rows="15" asp-for="Reason" type="text" name="Reason" id="Reason" maxlength="4096" class="form-control"></textarea>
<span asp-validation-for="Reason" class="text-danger"></span> @Html.HiddenFor(model=>model.Location.Latitude) @Html.HiddenFor(model=>model.Location.Longitude)
<span asp-validation-for="Reason" class="text-danger"></span>
@Html.HiddenFor(model=>model.Location.Latitude)
@Html.HiddenFor(model=>model.Location.Longitude)
</div>
</div>
</div>
@ -191,7 +193,7 @@
<input type="submit" value="@SR[" Create "]" class="btn btn-default" />
</div>
</div>
@Html.HiddenFor(model=>model.Client.Id)
@Html.HiddenFor(model=>model.ClientId)
@Html.HiddenFor(model=>model.PerformerId)
@Html.HiddenFor(model=>model.ActivityCode)
</div>