public IHttpActionResult PutCardRequest(int id, CardRequest cardRequest) { cardRequest.Date = DateTime.Now.Date; cardRequest.Time = DateTime.Now.TimeOfDay; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cardRequest.Id) { return(BadRequest()); } db.Entry(cardRequest).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CardRequestExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public static bool UpdateCardRequest(long cardRequestID, string requestType, string loggedInUsername) { try { string clearPan = string.Empty; CardRequest cardRequest = new CardRequest(); if (requestType == StatusUtil.RequestType.WithSerialNumber.ToString()) { List <KioskSolutionLibrary.ModelLibrary.EntityFrameworkLibrary.ThirdPartyData.PANDetail> unusedPans = ThirdPartyDL.RetrieveUnUsedPanDetails(); if (unusedPans.Count == 0) { throw new Exception("There are no available pans for linking"); } else { clearPan = unusedPans.Take(1).First().pan; } } bool updated = CustomerDL.UpdateCardRequest(cardRequestID, clearPan, loggedInUsername, out cardRequest); if (updated) { Mail.SendCardPickup(cardRequest); } return(updated); } catch (Exception ex) { throw ex; } }
public HttpResponseMessage SaveCustomerCardRequest([FromBody] CardRequestModel cardRequestModel) { try { CardRequest cardRequest = new CardRequest(); cardRequest.CustomerID = cardRequestModel.CustomerID; cardRequest.CardType = Enum.GetName(typeof(StatusUtil.CardType), cardRequestModel.CardTypeID); cardRequest.RequestType = Enum.GetName(typeof(StatusUtil.RequestType), cardRequestModel.RequestTypeID); cardRequest.PickupBranchID = cardRequestModel.PickupBranchID; cardRequest.Status = StatusUtil.CardStatus.Approved.ToString(); cardRequest.ModifiedDate = System.DateTime.Now; cardRequest.SerialNumber = cardRequestModel.SerialNumber; string username = cardRequestModel.Username; bool result = CustomerPL.SaveCardRequest(cardRequest, username); return(result.Equals(true) ? Request.CreateResponse(HttpStatusCode.OK, "Successful") : Request.CreateResponse(HttpStatusCode.BadRequest, "Request failed")); } catch (Exception ex) { ErrorHandler.WriteError(ex); var response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return(response); } }
public async Task <IActionResult> RequestSalaryCard(CardRequestViewModel cardRequestViewModel) { cardRequestViewModel.City = await _cityRepository.GetByIdAsync(cardRequestViewModel.City.Id); CardRequest cardRequest = cardRequestViewModel; if (ModelState.IsValid) { cardRequest.User = await userManager.GetUserAsync(User); cardRequest.UserId = cardRequest.User.Id; cardRequest.IsActive = true; await _cardRequestService.Add(cardRequest); await _cardRequestHistoryService.MakeHistory(cardRequest.UserId); return(RedirectToAction("Index", "Cards")); } else { ViewData["Cities"] = await _cityRepository.GetCitiesWithTrackingAsync(); return(View()); } }
public void ChargeCreateFromCard() { var row = this.TestContext.DataRow; //カードを作る CardRequest card = Helper.CreateCard(row); //課金を作成 ChargeRequest charge = new ChargeRequest(); charge.Amount = 500; charge.Description = "カードから直接課金"; charge.Card = card; var res = client.Charge.Create(charge); { Helper.AssertChargeReqAndRes(charge, res); Assert.AreEqual(res.AmountRefunded, 0); Assert.IsTrue(res.Captured); Assert.IsTrue(res.Paid); Assert.IsFalse(res.Refunded); Assert.IsNull(res.Customer); Assert.IsNull(res.FailureMessage); Helper.AssertCardAndCSV(res.Card, row); } //課金を検証 var retrieved = client.Charge.Retrieve(res.ID); { Helper.AssertChargeAndCharge(res, retrieved); } }
public static bool CustomerCardRequestExists(string serialNumber) { try { var existingCardRequest = new CardRequest(); using (var context = new KioskWebDBEntities()) { existingCardRequest = context.CardRequests .Where(t => t.SerialNumber.Equals(serialNumber)) .FirstOrDefault(); } if (existingCardRequest == null) { return(false); } else { return(true); } } catch (Exception ex) { throw ex; } }
public async Task <ActionResult <CardResponse> > PostCard(CardRequest cardRequest) { var cardResponse = await _cardService.Create(cardRequest); return(CreatedAtAction(nameof(GetCard), new { id = cardResponse.Value.Id }, cardResponse.Value)); }
public async Task Post_Method_Returns_CreatedAtAction_DeckExists() { //Arrange var mockRepository = new Mock <IFlashcardDataRepository>(); mockRepository.Setup(x => x.isDeckExist(1)).Returns((int id) => Task.FromResult(true)); mockRepository.Setup(x => x.AddCardToDeck(1, "q1", "a1")) .Returns((int id, string questionText, string answerText) => Task.FromResult(new Card() { Id = id, QuestionText = questionText, AnswerText = answerText })); CardsController cardsController = new CardsController(mockRepository.Object, iMapper); CardRequest cardRequest = new CardRequest() { QuestionText = "q1", AnswerText = "a1" }; //Act var result = await cardsController.Post(1, cardRequest); //Assert var createAtActionResult = Assert.IsType <CreatedAtActionResult>(result); var cardResponseDto = Assert.IsType <CardResponseDto>(createAtActionResult.Value); Assert.Equal(1, cardResponseDto.Id); Assert.Equal("q1", cardResponseDto.QuestionText); Assert.Equal("a1", cardResponseDto.AnswerText); }
public ActionResult CreateCard([FromBody] CardRequest request) { long cardId = _service.CreateCard(request); return(Ok(new { data = cardId })); }
private ExecutionResult GetCard(CardRequest request, ExecutionContext context) { var entity = AdbRepository.CardData.GetCardByNumber((string)request.Value); var dto = Mapper.Map <CardDto>(entity); return(new ExecutionResult <CardDto> { TypedResult = dto }); }
public static bool SaveCardRequest(CardRequest cardRequest, string loggedInUsername, out CardRequest savedCardRequest) { try { using (var context = new KioskWebDBEntities()) { using (var transaction = context.Database.BeginTransaction()) { context.CardRequests.Add(cardRequest); context.SaveChanges(); KioskSolutionLibrary.ModelLibrary.EntityFrameworkLibrary.ThirdPartyData.User thirdPartyUser = ThirdPartyDL.RetrieveUserByUsername(loggedInUsername); Customer cardRequestCustomer = RetrieveCustomerByID(cardRequest.CustomerID); KioskSolutionLibrary.ModelLibrary.EntityFrameworkLibrary.ThirdPartyData.CardAccountRequest car = new ModelLibrary.EntityFrameworkLibrary.ThirdPartyData.CardAccountRequest(); car.NameOnCard = string.Format("{0} {1}", cardRequestCustomer.Lastname, cardRequestCustomer.Othernames); if (cardRequest.RequestType == StatusUtil.RequestType.WithSerialNumber.ToString()) { KioskSolutionLibrary.ModelLibrary.EntityFrameworkLibrary.ThirdPartyData.PANDetail panDetail = ThirdPartyDL.RetrievePanDetailByAccountNumber(cardRequest.SerialNumber); car.PAN = panDetail.pan; ThirdPartyDL.UpdatePan(panDetail.pan); } car.PrintStatus = 1; car.UserPrinting = thirdPartyUser.id.ToString(); car.DATE = System.DateTime.Now; if (cardRequest.RequestType == StatusUtil.RequestType.WithSerialNumber.ToString()) { car.HolderIDNumber = cardRequest.SerialNumber; } car.PhoneNumber = cardRequestCustomer.PhoneNumber; car.LastName = cardRequestCustomer.Lastname; car.OtherName = cardRequestCustomer.Othernames; car.emailaddress = cardRequestCustomer.EmailAddress; car.Updateddate = System.DateTime.Now; ThirdPartyDL.SaveCar(car); cardRequest.Customer = cardRequestCustomer; transaction.Commit(); } } cardRequest.Branch = BranchDL.RetrieveBranchByID(cardRequest.PickupBranchID); savedCardRequest = cardRequest; return(true); } catch (Exception ex) { throw ex; } }
public async Task <ActionResult <CardResponse> > Create(CardRequest cardRequest) { var card = MapRequestToModel(cardRequest); card = await _cardRepository.Add(card); var cardResponse = MapModelToResponse(card); return(cardResponse); }
/// <summary> /// クレジットカード詳細を隠蔽する一度だけ使用可能な使い切りトークンを作成します。 /// このトークンは、このAPIのあらゆるメソッドで、クレジットカード情報の入ったディクショナリの代わりとして使用することができます。 /// これらのトークンは、使い捨てで一度しか使用することができません。 /// トークンは、新しい課金を行うか、もしくは顧客("customer")オブジェクトに紐づけるかの、二つの使い方があります。 /// </summary> /// <param name="card">クレジットカード情報</param> /// <returns>トークン</returns> public Token Create(CardRequest card) { HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, new Uri(parent.BaseUri, "tokens/")); message.Content = new FormUrlEncodedContent(card.ToFormContent(new Dictionary <string, string>())); Token retval = this.parent.SendRequest <Token>(message); return(retval); }
public async Task <IActionResult> PutCard(long id, CardRequest cardRequest) { if (id != cardRequest.Id) { return(BadRequest()); } await _cardService.Update(cardRequest); return(NoContent()); }
public void ChargeCreateFromToken() { var row = this.TestContext.DataRow; //カードを作る CardRequest card = Helper.CreateCard(row); //トークン作る Token token = this.client.Token.Create(card); { Assert.AreEqual(token.ObjectType, "token"); Assert.IsFalse(token.Used); Helper.AssertCardAndCSV(token.Cards, row); } //課金を作成 ChargeRequest charge = new ChargeRequest(); charge.Amount = 500; charge.Description = "トークンから課金"; charge.CardToken = token.ID; var res = client.Charge.Create(charge); { Helper.AssertChargeReqAndRes(charge, res); Assert.AreEqual(res.AmountRefunded, 0); Assert.IsTrue(res.Captured); Assert.IsTrue(res.Paid); Assert.IsFalse(res.Refunded); Assert.IsNull(res.Customer); Assert.IsNull(res.FailureMessage); Helper.AssertCardAndCSV(res.Card, row); } //課金を検証 var retrieved = client.Charge.Retrieve(res.ID); { Helper.AssertChargeAndCharge(res, retrieved); } //使い終わったトークンを検証 var usedToken = this.client.Token.Retrieve(token.ID); { Assert.AreEqual(usedToken.ObjectType, "token"); Assert.AreEqual(usedToken.Created, token.Created); Assert.IsTrue(usedToken.Used); Helper.AssertCardAndCard(token.Cards, usedToken.Cards); } }
public static CardRequest CreateCard(DataRow row) { CardRequest retval = new CardRequest(); retval.Number = row["CardNumber"].ToString(); retval.Name = row["Name"].ToString(); retval.ExpMonth = int.Parse(row["ExpMonth"].ToString()); retval.ExpYear = int.Parse(row["ExpYear"].ToString()); retval.CVC = int.Parse(row["CVC"].ToString()); return(retval); }
public async Task <IActionResult> PostCardEntity([FromBody] CardRequest cardRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var cardEntity = new CardEntity(cardRequest); _context.CardEntity.Add(cardEntity); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCardEntity", new { id = cardEntity.ID }, cardEntity)); }
public void TokenCreateFromCard() { var row = this.TestContext.DataRow; CardRequest card = Helper.CreateCard(row); var res = client.Token.Create(card); Assert.AreEqual(res.ObjectType, "token"); Assert.IsFalse(res.Used); Helper.AssertCardAndCSV(res.Cards, row); }
public IHttpActionResult DeleteCardRequest(int id) { CardRequest cardRequest = db.CardRequests.Find(id); if (cardRequest == null) { return(NotFound()); } db.CardRequests.Remove(cardRequest); db.SaveChanges(); return(Ok(cardRequest)); }
public long CreateCard(CardRequest request) { var newCard = new Card() { Name = request.Name, Priority = request.Priority, BoardId = request.BoardId }; _context.Cards.Add(newCard); _context.SaveChanges(); return(newCard.Id); }
public IHttpActionResult PostCardRequest(CardRequest cardRequest) { cardRequest.Time = DateTime.Now.TimeOfDay; cardRequest.Date = DateTime.Now.Date; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CardRequests.Add(cardRequest); db.SaveChanges(); return(CreatedAtRoute("PostCardRequest", new { id = cardRequest.Id }, cardRequest)); }
public async Task PlayCard_InvalidObjectPassed_ReturnsBadRequest() { // Arrange var cardRequest = new CardRequest() { isHigher = true }; controller.ModelState.AddModelError("Id", "Required"); // Act var badResponse = await controller.PlayCard(cardRequest); // Assert Assert.IsType <NotFoundObjectResult>(badResponse); }
public Card MapRequestToModel(CardRequest cardRequest) { if (cardRequest == null) { return(null); } var card = new Card { Id = cardRequest.Id, Title = cardRequest.Title, ListId = cardRequest.ListId, AssigneId = cardRequest.AssigneId, DueDate = cardRequest.DueDate }; return(card); }
public static bool SaveCardRequest(CardRequest cardRequest, string username) { try { CardRequest savedCardRequest = new CardRequest(); bool saved = CustomerDL.SaveCardRequest(cardRequest, username, out savedCardRequest); if (saved) { Mail.SendCardPickup(savedCardRequest); } return(saved); } catch (Exception ex) { throw ex; } }
public void CustomerCreate() { var row = this.TestContext.DataRow; CardRequest card = Helper.CreateCard(row); CustomerRequest customer = new CustomerRequest(); customer.Email = "*****@*****.**"; customer.Description = "普通にできるはず"; customer.Card = card; var res = client.Customer.Create(customer); res.Email = "*****@*****.**"; res.Description = "普通にできるはず"; Helper.AssertCardAndCSV(res.ActiveCard, row); }
public async Task <IActionResult> Create([FromBody] CardRequest request, CancellationToken cancellationToken) { if (request == null) { return(BadRequest()); } var commandInput = new CreateCardCommandInput(request.CustomerId, request.CardNumber, request.CVV); var commandResult = await _mediator.Send(commandInput, cancellationToken); if (!commandResult.IsValid()) { return(BadRequest()); } var response = new CardResponse(commandResult.CreationDate, commandResult.Token, commandResult.CardId); return(Created($"/v1/cards/{response.CardId}", response)); }
public async Task PlayCard_ValidObjectPassed_ReturnsOkResponse() { // Arrange List <Room> listRoom = GetRooms(); var cardRequest = new CardRequest() { Id = listRoom.FirstOrDefault().ID, isHigher = true }; // Act mock.Setup(m => m.ListCardsAsync()).ReturnsAsync(listRoom); var controllerCard = new CardController(mock.Object); var okResponse = await controllerCard.PlayCard(cardRequest); // Assert Assert.IsType <OkObjectResult>(okResponse); }
public void CustomerCreateError() { var row = this.TestContext.DataRow; CardRequest card = Helper.CreateCard(row); CustomerRequest cus = new CustomerRequest(); cus.Card = card; cus.Email = "*****@*****.**"; cus.Description = "エラーが起こるパターン"; try { var res = client.Customer.Create(cus); } catch (CardException e) { Assert.AreEqual(e.Code, row["ErrorCode"].ToString()); } }
/// <summary> /// Create an access token /// </summary> internal static string CreateToken(AuthService authService) { var tokenRequest = new TokenRequest(); tokenRequest.clientKey = Configuration.ClientKey; var cardRequest = new CardRequest(); cardRequest.cardNumber = TestMastercardNumber; cardRequest.cvc = TestCvv; cardRequest.name = "csharplib client"; cardRequest.expiryMonth = 2; cardRequest.expiryYear = 2018; cardRequest.type = "Card"; tokenRequest.paymentMethod = cardRequest; TokenResponse response = authService.GetToken(tokenRequest); return(response.token); }
public async Task Create_ShouldReturnBadRequest_WhenPassWrongParameters(int customerId, long cardNumber, int cvv) { // Arrange const string url = "/v1/cards"; var request = new CardRequest { CustomerId = customerId, CardNumber = cardNumber, CVV = cvv }; var json = JsonConvert.SerializeObject(request); var content = new StringContent(json, Encoding.UTF8, "application/json"); // Act var response = await _testsFixture.Client.PostAsync(url, content); // Assert response.StatusCode.Should().Be(HttpStatusCode.BadRequest); }
public void sendRequest(CardRequest request) { switch (request) { case CardRequest.REQ_FLOP: socket.Emit("flop"); break; case CardRequest.REQ_TURN: socket.Emit("turn"); break; case CardRequest.REQ_RIVER: socket.Emit("river"); break; case CardRequest.REQ_RESULT: socket.Emit("result"); break; } }
private void PostCardDetails() { if (log.IsInfoEnabled) log.Info("Postcarddetails started"); try { CardRequest request = new CardRequest { Ac = this.TransactionContext.AC, AcInfo = this.TransactionContext.ACInfo, AID = this.TransactionContext.AID, AppName = this.TransactionContext.AppName, AuthNum = this.TransactionContext.AuthNum, KioskTxnRefNum = this.TransactionContext.Id, MerchantId = this.TransactionContext.MerchantID, TerminalId = this.TransactionContext.TerminalID, TSI = this.TransactionContext.TSI, TVR = this.TransactionContext.TVR, CardNumber = this.TransactionContext.CardNo }; if (Boolean.Parse(ConfigurationManager.AppSettings["StandAloneMode"])) { Thread.Sleep(1000); this.TransactionContext.AppliedFee = 2.35; if (log.IsInfoEnabled) log.InfoFormat("Post Card Details in Stimulation Mode : {0}", TransactionContext.Id); } else { using (CardServiceClient client = new CardServiceClient()) { int result = client.PostCardDetails(request); if (result > 1) { if (log.IsInfoEnabled) log.InfoFormat("Card Details posted successfully for TxnRefnum : {0}", TransactionContext.Id); } else { if (log.IsInfoEnabled) log.InfoFormat("Card Details Posting failed for TxnRefnum : {0}", TransactionContext.Id); } } } } catch (Exception ex) { if (log.IsErrorEnabled) log.ErrorFormat("Error while Posting card details : {0}", ex.Message); } if (log.IsInfoEnabled) log.Info("Postcarddetails completed"); }