public async Task <ResultEntity> AddOrUpdateAsync(Card card) { var result = new ResultEntity(); var exist = await _cardRepository.GetQueryable().Where(a => a.Value == card.Value && a.Id != card.Id) .CountAsync() > 0; if (exist) { result.Message = "整卡卡号重复"; } else { if (card.Id > 0) { _cardRepository.Update(card); } else { await _cardRepository.AddAsync(card); } result.Success = true; } return(result); }
public async Task <Models.Card> CreateCardAsync(CreateCardModel createCardReq) { var request = _mapper.Map <PlayerRequest>(createCardReq); var player = await _bus.RequestAsync <PlayerRequest, PlayerResponse>(request); var random = new Random(); int index = random.Next(player.Positions.Length); var position = createCardReq.Position != null?player.Positions.First(x => x == createCardReq.Position) : player.Positions[index]; var card = new Models.Card() { Id = Guid.NewGuid(), PlayerId = player.Id, UserId = createCardReq.UserId, Name = player.Name, ShortName = player.ShortName, Position = position, Rating = player.Rating, Rarity = CardRarity(player.Rating), Form = player.Form, Opened = true, Fitness = 100, CreatedOn = DateTime.Now }; await _cardRepository.AddAsync(card); return(card); }
public async Task <Guid> CreateCardAsync(Card card) { card.Id = Guid.NewGuid(); card.CreatedAt = DateTime.Now; await _cardRepository.AddAsync(card); return(card.Id); }
public async Task <bool> CreateCardItemAsync(CardViewModel cardToCreate) { var card = _mapper.Map <CardViewModel, Card>(cardToCreate); await _cardRepository.AddAsync(card); await _cardRepository.CommitAsync(); cardToCreate.Id = card.Id; return(true); }
public async Task IsCreationCardWithoutImageSuccessful(CreationCardDto dto) { var dbo = mapper.Map <CardDbo>(dto); var result = await cardRepository.AddAsync(dbo); var found = await cardRepository.FindAsync(result.Id); result.Answer.Should().BeEquivalentTo(dbo.Answer); result.Question.Should().BeEquivalentTo(dbo.Question); result.ImagePath.Should().BeNull(); found.Should().Be(result); }
public async Task <CardResponse> SaveAsync(Card card) { try { await cardRepository.AddAsync(card); await unitOfWork.CompleteAsync(); return(new CardResponse(card)); } catch (Exception ex) { return(new CardResponse($"Ошибка при сохранении Карты: {ex.Message}")); } }
public async Task <CreateCardCommandResult> Handle(CreateCardCommandInput command, CancellationToken cancellationToken) { var customerId = command.CustomerId; var number = command.CardNumber; var cvv = command.CVV; var token = CardHelper.GenerateToken(number, cvv); var card = new Card(customerId, number, token); await _cardRepository.AddAsync(card, cancellationToken); await _cardRepository.UnitOfWork.CommitAsync(cancellationToken); return(new CreateCardCommandResult(card.CreationDate, card.Token, card.Id)); }
public async Task <IActionResult> AddAsync([FromBody] Card item) { if (item == null || !ModelState.IsValid) { return(BadRequest()); } var item2 = await _repository.AddAsync(item); if (item2 == null) { return(BadRequest()); } return(CreatedAtRoute("GetCollection", new { id = item2.Id }, item2)); }
public async Task <string> Handle(CreateCardCommand request, CancellationToken cancellationToken) { var userMail = _applicationUser.Email; var entity = new Card { Content = request.Content, CreatedBy = userMail, IsDone = request.IsDone, Title = request.Title, Created = DateTime.Now, ExpireTime = request.ExpireTime, NotificationEmail = string.IsNullOrEmpty(request.NotificationEmail) ? userMail : request.NotificationEmail }; await _repository.AddAsync(entity, cancellationToken); return(entity.Id); }
/// <summary> /// Adds a card /// </summary> /// <param name="card">The card object</param> public async Task AddAsync(BusinessCard card) { await _repo.AddAsync(card); }