private CreateApplicationDraftCommand MapToApplicationDraftCommand(BasketData basketData) { var command = new CreateApplicationDraftCommand { StudentId = basketData.StudentId, }; basketData.Items.ForEach(i => command.Items.Add(new BasketItem { Id = i.Id, OldSlotAmount = (double)i.OldSlotAmount, PictureUrl = i.PictureUrl, ScholarshipItemId = i.ScholarshipItemId, ScholarshipItemName = i.ScholarshipItemName, Slots = i.Slots, SlotAmount = (double)i.Slots, })); return(command); }
public async Task <ActionResult <ApplicationDraftDTO> > CreateApplicationDraftFromBasketDataAsync([FromBody] CreateApplicationDraftCommand createApplicationDraftCommand) { _logger.LogInformation( "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", createApplicationDraftCommand.GetGenericTypeName(), nameof(createApplicationDraftCommand.StudentId), createApplicationDraftCommand.StudentId, createApplicationDraftCommand); return(await _mediator.Send(createApplicationDraftCommand)); }
public override async Task <ApplicationDraftDTO> CreateApplicationDraftFromBasketData(CreateApplicationDraftCommand createApplicationDraftCommand, ServerCallContext context) { _logger.LogInformation("Begin grpc call from method {Method} for applying get application draft {CreateApplicationDraftCommand}", context.Method, createApplicationDraftCommand); _logger.LogTrace( "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", createApplicationDraftCommand.GetGenericTypeName(), nameof(createApplicationDraftCommand.StudentId), createApplicationDraftCommand.StudentId, createApplicationDraftCommand); var command = new AppCommand.CreateApplicationDraftCommand( createApplicationDraftCommand.StudentId, this.MapBasketItems(createApplicationDraftCommand.Items)); var data = await _mediator.Send(command); if (data != null) { context.Status = new Status(StatusCode.OK, $" applying get application draft {createApplicationDraftCommand} do exist"); return(this.MapResponse(data)); } else { context.Status = new Status(StatusCode.NotFound, $" applying get application draft {createApplicationDraftCommand} do not exist"); } return(new ApplicationDraftDTO()); }