public async Task <IActionResult> CreateNoteAsync( [FromBody] Client.Notes.NoteBuildInfo clientBuildInfo, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (!this.TryGetSessionState(this.HttpContext.Request.Cookies, out var state)) { return(this.Unauthorized()); } if (!this.ModelState.IsValid) { var error = ServiceErrorResponses.BodyIsMissing(nameof(Client.Notes.NoteBuildInfo)); return(this.BadRequest(error)); } var modelBuildInfo = NoteBuildInfoConverter.Convert(state.UserId.ToString(), clientBuildInfo); var modelNoteInfo = await this.repository.CreateAsync(modelBuildInfo, cancellationToken).ConfigureAwait(false); var clientNoteInfo = NoteInfoConverter.Convert(modelNoteInfo); var routeParams = new Dictionary <string, object> { { "noteId", clientNoteInfo.Id } }; return(this.CreatedAtRoute("GetNoteRoute", routeParams, clientNoteInfo)); }
public async Task <IActionResult> CreateNoteAsync([FromBody] Client.Notes.NoteBuildInfo buildInfo, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (buildInfo == null) { var error = ServiceErrorResponses.BodyIsMissing("NoteBuildInfo"); return(this.BadRequest(error)); } var userId = Guid.Empty.ToString(); // Нужно исправить var creationInfo = NoteBuildInfoConverter.Convert(userId, buildInfo); var modelNoteInfo = await this.repository.CreateAsync(creationInfo, cancellationToken).ConfigureAwait(false); var clientNoteInfo = NoteInfoConverter.Convert(modelNoteInfo); var routeParams = new Dictionary <string, object> { { "noteId", clientNoteInfo.Id } }; return(this.CreatedAtRoute("GetNoteRoute", routeParams, clientNoteInfo)); }