コード例 #1
0
 public async Task <IActionResult> PostDestinationAsync([FromBody] DestinationWriteResource record)
 {
     repo.Create(mapper.Map <DestinationWriteResource, Destination>(await AttachUserIdToRecord(record)));
     return(StatusCode(200, new {
         response = ApiMessages.RecordCreated()
     }));
 }
コード例 #2
0
 public IActionResult PostDestination([FromBody] Destination record)
 {
     if (ModelState.IsValid)
     {
         try {
             repo.Create(record);
             return(StatusCode(200, new {
                 response = ApiMessages.RecordCreated()
             }));
         } catch (Exception exception) {
             LoggerExtensions.LogException(0, logger, ControllerContext, record, exception);
             return(StatusCode(490, new {
                 response = ApiMessages.RecordNotSaved()
             }));
         }
     }
     LoggerExtensions.LogException(0, logger, ControllerContext, record, null);
     return(StatusCode(400, new {
         response = ApiMessages.InvalidModel()
     }));
 }
コード例 #3
0
        public void Create(DestinationModel model)
        {
            var destination = _mapper.Map <Destination>(model);

            _destinationRepository.Create(destination);
        }