public async Task <(Result result, string cardId)> RegisterAsync(CreateCardCommand model) { var salt1 = Guid.NewGuid().ToString(); var salt2 = Guid.NewGuid().ToString(); var card = new Card { Id = Guid.NewGuid().ToString(), CitizenId = model.OwnerId, Pin1Hash = _hashService.Create(model.Pin1, salt1), Pin1Salt = salt1, Pin2Hash = _hashService.Create(model.Pin2, salt2), Pin2Salt = salt2, Active = true, IssueDate = DateTime.UtcNow.AddHours(-2), TerminationDate = DateTime.UtcNow.AddYears(4), Email = model.Email, PhoneNumber = model.PhoneNumber, CardIssuer = _currentUser.CitizenId, UserName = Guid.NewGuid().ToString() }; var result = await _userManager.CreateAsync(card, model.Puk); return(result.ToResult(), card.Id); }
public UserMessage CreateCard(CreateCardCommand command) { EnsureIsValid(command); try { var cardAccount = _deps.CardAccounts.SurelyFind(command.AccountNo); var user = _deps.Users.SurelyFind(command.UserId); var cardVendor = _deps.CardVendors.SurelyFind(command.CardVendorId); var userCard = _deps.UserCardFactory.Create( cardAccount, cardVendor, user, command.CardholderFirstName, command.CardholderLastName, command.ExpirationDateUtc); _deps.UserCards.Create(userCard); Commit(); return(UserMessage.ResourceFormat(() => Messages.CardEmitted, userCard.CardNo)); } catch (ServiceException) { throw; } catch (Exception ex) { throw new ServiceException("Cannot create card.", ex); } }
public async Task <Result <CommandResult> > Handle(CreateCardCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { await PublishValidationErrorsAsync(request); return(Result.Failure <CommandResult>(ApplicationMessages.Create_Failed)); } var project = _mapper.Map <Card>(request); var exist = await _projectRepository.ExistByNameAsync(project.Id, project.Name); if (exist) { await _mediator.Publish(new DomainNotification("", ApplicationMessages.Name_Already_Exist)); return(Result.Failure <CommandResult>(ApplicationMessages.Create_Failed)); } await _projectRepository.CreateAsync(project); return(Result.Success(new CommandResult(project.Id, ApplicationMessages.Create_Success))); }
public Task <CreateCardCommandResult> CreateCard(CreateCardCommand command) { Task <CreateCardCommandResult> result; result = _mediator.Send(command); return(result); }
public async Task <IActionResult> CreateCardAsync([FromBody] CreateCardCommand command) { if (command == null) { return(BadRequest()); } var result = await _cardsClient.CreateCardAsync(command); return(Ok(result)); }
public async Task <CardResponse> CreateCardAsync(CreateCardCommand command) { using var channel = GrpcChannel.ForAddress(_options.Uri); var client = new Cards.CardsService.CardsServiceClient(channel); var grpcRequest = command.ToGrpcRequest(); var grpcResponse = await client.CreateCardAsync(grpcRequest); var response = CardResponse.FromGrpcResponse(grpcResponse); return(response); }
public async Task <IActionResult> Post([FromBody] CreateCardRequest request) { var command = new CreateCardCommand(request.Number, request.CardHolder, request.ExpirationDate); var result = await commandDispatcher.Dispatch(command); if (result.Success) { var response = new CreateCardResponse() { Id = result.Id, Number = result.Number, CardHolder = result.CardHolder, ExpirationDate = result.ExpirationDate }; return(Ok(response)); } return(BadRequest(request)); }
public async Task <IActionResult> CreateCardAsync([FromBody] CreateCardCommand command) { if (command == null) { return(BadRequest()); } var cardToCreate = new Card { Name = command.Name, Description = command.Description }; var createdCard = await _cardsService.CreateCardAsync(cardToCreate); var response = new CardResponse { Id = createdCard.Id, Name = createdCard.Name, Description = createdCard.Description }; return(Ok(response)); }
public IHttpActionResult CreateCard(CreateCardCommand command) { return(Ok(_cardAccountService.CreateCard(command))); }
public async Task <ActionResult <CardViewModel> > Create([FromBody] CreateCardCommand command) { var vm = await Mediator.Send(command); return(Ok(vm)); }
public async Task <ActionResult <string> > Post([FromBody] CreateCardCommand command) { var cardId = await Mediator.Send(command); return(Ok(cardId)); }
public async Task <ActionResult <int> > Create(CreateCardCommand command) { return(await Mediator.Send(command)); }
public WebApiResult <CardItem> Post([FromBody] CreateCardCommand command) { var result = _repository.ExecuteCommand(command); return(AutoMapper.Mapper.Map <CommandResult <Card>, WebApiResult <CardItem> >(result)); }
public async Task <IActionResult> CreateCard([FromBody] CreateCardCommand command) { return(Ok(await Mediator.Send(command))); }
public async Task <ActionResult <CardDto> > Create([FromBody] CreateCardCommand command) { var result = await _mediator.Send(command); return(Ok(result)); }
public async Task <ActionResult <string> > Create([FromBody] CreateCardCommand command) { string productId = await _mediator.Send(command); return(Ok(productId)); }
public async Task <IActionResult> Create([FromBody] CreateCardCommand cardCommand) { var card = await Mediator.Send(cardCommand); return(Ok(card)); }