private async Task <CrewWriteResource> AttachUserIdToRecord(CrewWriteResource record) { var user = await Identity.GetConnectedUserId(httpContext); record.UserId = user.UserId; return(record); }
public int IsValid(CrewWriteResource record) { return(true switch { var x when x == !IsValidGender(record) => 450, var x when x == !IsValidNationality(record) => 451, var x when x == !IsValidShip(record) => 453, _ => 200, });
public async Task <IActionResult> PutAsync([FromBody] CrewWriteResource record) { var response = repo.IsValid(record); if (response == 200) { repo.Update(mapper.Map <CrewWriteResource, Crew>(await AttachUserIdToRecord(AttachOccupantIdToRecord(record)))); return(StatusCode(200, new { response = ApiMessages.RecordUpdated() })); } else { return(GetErrorMessage(response)); } }
private static CrewWriteResource AttachOccupantIdToRecord(CrewWriteResource record) { record.OccupantId = 1; return(record); }