public async Task <bool> Handle(CreateEntryRequest message, IOutputPort <ServiceResponse> outputPort) { var response = await _entryRepository.Create(message.Name, message.PhoneNumber, message.PhoneBookId); outputPort.Handle(response.Success ? new ServiceResponse(response.Id, true) : new ServiceResponse(response.Errors.Select(e => e.Description))); return(response.Success); }
/// <summary> /// Create a blog entry. /// </summary> /// <remarks> /// Sample request: /// /// POST /Create /// { /// "Title": "Blog title or subject", /// "Content": { /// "Html": "Some html content" /// } /// } /// /// </remarks> /// <param name="createEntryModel"></param> /// <returns><see cref="OkResult"/></returns> /// <response code="200">Returns ok result</response> /// <response code="400">If the information is not valid</response> public async Task <IActionResult> Create([FromBody] CreateEntryRequest createEntryModel) { if (!ModelState.IsValid) { return(ValidationProblem()); } await Mediator.Send(createEntryModel).ConfigureAwait(false); return(Ok()); }
public async Task <ActionResult> Create(CreateEntryRequest createEntryRequest) { var entry = _mapper.Map <Entry>(createEntryRequest); await _entryAccess.CreateAsync(entry); var entryResponse = _mapper.Map <EntryResponse>(entry); var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}"; var locationUri = baseUrl + "/" + ApiRoutes.Entry.GetOne.Replace("{entryId}", entry.Id.ToString()); return(Created(locationUri, entryResponse)); }
/// <summary>Snippet for CreateEntry</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void CreateEntryRequestObject() { // Create client DataCatalogClient dataCatalogClient = DataCatalogClient.Create(); // Initialize request argument(s) CreateEntryRequest request = new CreateEntryRequest { ParentAsEntryGroupName = EntryGroupName.FromProjectLocationEntryGroup("[PROJECT]", "[LOCATION]", "[ENTRY_GROUP]"), Entry = new Entry(), EntryId = "", }; // Make the request Entry response = dataCatalogClient.CreateEntry(request); }