Example #1
0
        public async Task <IActionResult> Add([FromBody] AddWalletDto walletDto)
        {
            walletDto.Owner = Username;
            await _walletService.AddWallet(walletDto)
            .ConfigureAwait(false);

            return(NoContent());
        }
        public async Task <IActionResult> CreateNew([FromBody] AddWalletDto addWalletDto)
        {
            var result = await _walletService.CreateWallet(addWalletDto, UserId);

            if (!result.Succedeed)
            {
                return(BadRequest());
            }
            return(Ok(result.Value));
        }
Example #3
0
        public async Task <int> AddWalletAsync(AddWalletDto dto)
        {
            Wallet newWallet = dto.ToEntity();

            _dbContext.Wallets.Add(newWallet);

            await _dbContext.SaveChangesAsync();

            return(newWallet.Id);
        }
Example #4
0
        public async Task <Result <string> > CreateWallet(AddWalletDto addWalletDto, string userId)
        {
            var wallet = Mapper.Map <Wallet>(addWalletDto);

            wallet.CreatorId = userId;

            var userWallet = new UserWallet
            {
                Role   = WalletRole.Creator,
                Wallet = wallet,
                UserId = userId
            };

            await _walletRepository.Add(userWallet);

            return(userWallet.WalletId != default(int)
                ? Result <string> .Success(userWallet.WalletId.ToObfuscated())
                : Result <string> .Failure());
        }
Example #5
0
 public static Wallet ToEntity(this AddWalletDto dto) => new Wallet
 {
     Name   = dto.Name,
     UserId = dto.UserId
 };
 public async Task AddWallet(AddWalletDto wallet)
 {
     var result = _mapper.Map <AddWalletDto, Wallet>(wallet);
     await _walletRepository.CreateWalletAsync(result)
     .ConfigureAwait(false);
 }