コード例 #1
0
        private async Task <CrewWriteResource> AttachUserIdToRecord(CrewWriteResource record)
        {
            var user = await Identity.GetConnectedUserId(httpContext);

            record.UserId = user.UserId;
            return(record);
        }
コード例 #2
0
 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,
     });
コード例 #3
0
        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));
            }
        }
コード例 #4
0
 private static CrewWriteResource AttachOccupantIdToRecord(CrewWriteResource record)
 {
     record.OccupantId = 1;
     return(record);
 }