public async Task <IActionResult> PostDestinationAsync([FromBody] DestinationWriteResource record) { repo.Create(mapper.Map <DestinationWriteResource, Destination>(await AttachUserIdToRecord(record))); return(StatusCode(200, new { response = ApiMessages.RecordCreated() })); }
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() })); }
public void Create(DestinationModel model) { var destination = _mapper.Map <Destination>(model); _destinationRepository.Create(destination); }