public bool Register(string username, string password, UserInfoDTO userinfo, CardInfoDTO cardInfo, AdressDTO addres) { try { var acc = this._accountDal.CreateAccount(username, password); addres = _adressDal.CreateAdress(addres); cardInfo = _cardinfoDal.CreateBankCardInfo(cardInfo); userinfo.UserID = acc.UserID; userinfo.BankCardInfoID = (int)cardInfo.CardInfoID; userinfo.AdressID = (int)addres.AdressID; this._userInfoDal.CreateUserInfo(userinfo); // transaction? } catch (Exception exp) { if (exp.Message == "User already exists!") { return(false); } throw exp; } return(true); }
public async Task <IActionResult> ProcessPayment([FromBody] CardInfoDTO cardInfo) { try { if (cardInfo == null) { _logger.LogError("CardInfo object sent from client is null."); return(BadRequest("CardInfo object is null")); } if (!ModelState.IsValid) { return(BadRequest("Invalid model object")); } var response = await _processPaymentService.ProcessPayment(cardInfo); return(Ok(response)); } catch (Exception ex) { _logger.LogError($"Something went wrong inside ProcessPayment action: {ex.Message}"); return(StatusCode(500, "Internal Server Error")); } }
public CardInfoDTO UpdateCardInfo(CardInfoDTO card) { using (var e = new EntityTC()) { e.CardInfo.AddOrUpdate(_mapper.Map <CardInfo>(card)); var res = e.CardInfo.Single(p => p.CardInfoID == card.CardInfoID); return(_mapper.Map <CardInfoDTO>(res)); } }
public CardInfoDTO CreateCardInfo(CardInfoDTO card) { using (var e = new EntityTC()) { CardInfo info = _mapper.Map <CardInfo>(card); e.CardInfo.Add(info); e.SaveChanges(); return(_mapper.Map <CardInfoDTO>(info)); } }
public async Task <APIResponse> ProcessPayment(CardInfoDTO request) { var response = new APIResponse(); try { var amount = request.Amount; if (amount < 20) { response = await _cheapPaymentGateway.ProcessCheapPayment(request); } else if (amount >= 21 && amount <= 500) { if (_expensivePaymentGateway != null) { response = await _expensivePaymentGateway.ProcessExpensivePayment(request); } else { response = await _cheapPaymentGateway.ProcessCheapPayment(request); } } else if (amount > 500) { int count = 0; response = await _premiumPayment.ProcessPremiumPayment(request); if (response.Code == "99") { while (response.Code == "99" && count <= 3) { response = await _premiumPayment.ProcessPremiumPayment(request); count++; } } } else { response = new APIResponse { Code = "99", Description = "Your payment cannot be processed", Data = "" }; } var paymentState = new PaymentState(); paymentState.CorrelationId = Guid.NewGuid().ToString(); paymentState.PayDate = DateTime.Now; paymentState.RequestString = JsonTranformer.SerializeObject(request); paymentState.ResponseString = JsonTranformer.SerializeObject(response); if (response.Code == "00") { paymentState.State = State.processed; } if (response.Code == "99") { paymentState.State = State.failed; } else { paymentState.State = State.pending; } _repositoryWrapper.PaymentStateRepository.Create(paymentState); await _repositoryWrapper.SaveAsync(); } catch (Exception) { response = new APIResponse { Code = "99", Description = "Internal Server Error", Data = "" }; throw; } return(response); }
public CardInfoDTO CardInfo(int id) { this.ConnectToDatabase(); MySqlCommand command = this.mySQLConnection.CreateCommand(); command.CommandText = "SELECT * FROM CARD WHERE CARD_ID = " + id; MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { int cardId = reader.GetInt32(0); int listId = reader.GetInt32(1); int indexCard = reader.GetInt32(2); string title = reader.GetString(3); string description = reader.GetString(4); int label = reader.GetInt32(5); DateTime dueDate = (reader.IsDBNull(6)) ? DateTime.MinValue : (reader.GetDateTime(6)); float status = reader.GetInt64(7); card = new CardDTO(cardId, listId, indexCard, title, description, label, dueDate, status); } reader.Close(); command.CommandText = "SELECT * FROM CHECKLIST WHERE CARD_ID = '" + id + "' AND STATUS = '" + 1 + "'"; MySqlDataReader reader1 = command.ExecuteReader(); while (reader1.Read()) { int checklistId = reader1.GetInt32(0); int cardId = reader1.GetInt32(1); int checklistIndex = reader1.GetInt32(2); string title = reader1.GetString(3); byte status = reader1.GetByte(4); ChecklistDTO checklist = new ChecklistDTO(checklistId, cardId, checklistIndex, title, status); listCheckedlist.Add(checklist); } countCheckedlist = listCheckedlist.Count(); reader1.Close(); command.CommandText = "SELECT * FROM CHECKLIST WHERE CARD_ID = '" + id + "'"; MySqlDataReader reader2 = command.ExecuteReader(); while (reader2.Read()) { int checklistId = reader2.GetInt32(0); int cardId = reader2.GetInt32(1); int checklistIndex = reader2.GetInt32(2); string title = reader2.GetString(3); byte status = reader2.GetByte(4); ChecklistDTO checklist = new ChecklistDTO(checklistId, cardId, checklistIndex, title, status); listChecklist.Add(checklist); } countChecklist = listChecklist.Count(); reader2.Close(); command.CommandText = "SELECT * FROM USERS WHERE USER_ID = " + id; MySqlDataReader reader3 = command.ExecuteReader(); while (reader3.Read()) { int userId = reader3.GetInt32(0); string username = reader3.GetString(1); string password = reader3.GetString(2); string name = reader3.GetString(3); user = new CardUserDTO(userId, username, password, name); } reader3.Close(); command.CommandText = "SELECT u.NAME " + " FROM USERS u, LAMVIEC l " + " WHERE u.USER_ID = l.USER_ID and CARD_ID = " + id; MySqlDataReader reader4 = command.ExecuteReader(); while (reader4.Read()) { string name = reader4.GetString(0).Substring(0, 1); listNameUser.Add(name); } reader4.Close(); command.CommandText = "SELECT * FROM COMMENT WHERE CARD_ID = '" + id + "'"; MySqlDataReader reader5 = command.ExecuteReader(); while (reader5.Read()) { int userId = reader5.GetInt32(1); string content = reader5.GetString(2); DateTime time = reader5.GetDateTime(3); int cmtIndex = reader5.GetInt32(4); CommentDTO comment = new CommentDTO(id, userId, content, time, cmtIndex); listComment.Add(comment); } countCmt = listComment.Count(); reader5.Close(); this.Close(); CardInfoDTO cardInfoDTO = new CardInfoDTO(this.card, this.listNameUser, countChecklist, countCheckedlist, this.user, countCmt); return(cardInfoDTO); GC.Collect(); }
//==================================================== //[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")] //private static extern IntPtr CreateRoundRectRgn //( // int nLeftRect, // x-coordinate of upper-left corner // int nTopRect, // y-coordinate of upper-left corner // int nRightRect, // x-coordinate of lower-right corner // int nBottomRect, // y-coordinate of lower-right corner // int nWidthEllipse, // height of ellipse // int nHeightEllipse // width of ellipse //); //public static System.Drawing.Region GetRoundedRegion(int controlWidth, int controlHeight) //{ // return System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, controlWidth - 2, controlHeight - 2, 10, 10)); //} public Card(int X, int cardId, int index, ListSpace listSpace) { InitializeComponent(); _cardId = cardId; oX = X; oY = 3 + (index + 3) * this.Height; _listSpace = listSpace; //this.Region = GetRoundedRegion(this.Width, this.Height); cardInfoBLL = new CardInfoBLL(); cardInfoDTO = cardInfoBLL.CardInfo(_cardId); cardDTO = cardInfoDTO.Card; listNameUser = cardInfoDTO.ListNameUser; CardName.Text = cardDTO.Title; dateCard.Text = cardDTO.DueDate.ToShortDateString(); if (cardInfoDTO.CountCmt != 0) { panel2.Visible = true; label3.Text = cardInfoDTO.CountCmt.ToString(); } else { panel2.Visible = false; } if (cardDTO.Description == null || cardDTO.Description == "") { this.desPicture.Visible = false; } else { this.desPicture.Visible = true; } foreach (string name in listNameUser) { MemIcon member = new MemIcon(name, 25, 25); this.flowLayoutPanel3.Controls.Add(member); } if (cardDTO.Description.Equals("")) { this.desPicture.Visible = false; } else { this.desPicture.Visible = true; } switch (cardDTO.Label) { case 1: this.CardLabel.BackColor = Color.Red; break; case 2: this.CardLabel.BackColor = Color.Yellow; break; case 3: this.CardLabel.BackColor = Color.Green; break; case 4: this.CardLabel.BackColor = Color.Orange; break; case 5: this.CardLabel.BackColor = Color.Blue; break; case 6: this.CardLabel.BackColor = Color.Fuchsia; break; default: this.CardLabel.BackColor = Color.Transparent; break; } if (cardInfoDTO.CountChecklist != 0) { checkBox1.Visible = true; checkBox1.Text = cardInfoDTO.CountCheckedlist + "/" + cardInfoDTO.CountChecklist; } else { checkBox1.Visible = false; } }
public async Task <APIResponse> ProcessPremiumPayment(CardInfoDTO cardInfo) { return(await Task.Run(() => new APIResponse { Code = "00", Description = "Success", Data = "" })); }
/// <summary> /// 获取玩家拥有的卡片列表 /// </summary> private void RequestPlayerCardList() { SocketModel model = new SocketModel(); model.protocol = SocketProtocol.CARDINFOLIST; CardInfoDTO data = new CardInfoDTO() { cardOwnerId = Global.Instance.playerInfo.uid }; model.message = JsonCoding<CardInfoDTO>.encode(data); cardClient.SendMsg(JsonCoding<SocketModel>.encode(model)); }
public async Task <APIResponse> ProcessExpensivePayment(CardInfoDTO request) { return(await Task.Run(() => new APIResponse { })); }
public async Task <APIResponse> ProcessCheapPayment(CardInfoDTO cardInfo) { return(await Task.Run(() => new APIResponse { })); }
public CardEdit(int X, int Y, int cardId, ListSpace listSpace) { InitializeComponent(); _cardId = cardId; _listSpace = listSpace; cardDTO = cardBLL.GetCard(_cardId); cardInfoBLL = new CardInfoBLL(); commentBLL = new CommentBLL(); cardInfoDTO = cardInfoBLL.CardInfo(_cardId); listNameUser = cardInfoDTO.ListNameUser; this.Location = new Point(X, Y); this.StartPosition = FormStartPosition.CenterScreen; switch (cardDTO.Label) { case 1: this.CardLabel.BackColor = Color.Red; break; case 2: this.CardLabel.BackColor = Color.Yellow; break; case 3: this.CardLabel.BackColor = Color.Green; break; case 4: this.CardLabel.BackColor = Color.Orange; break; case 5: this.CardLabel.BackColor = Color.Blue; break; case 6: this.CardLabel.BackColor = Color.Fuchsia; break; default: this.CardLabel.BackColor = Color.Transparent; break; } this.cardName.Text = cardDTO.Title; this.dateTime.Text = cardDTO.DueDate.ToShortDateString(); if (cardDTO.Description == null || cardDTO.Description == "") { this.desPic.Visible = false; } else { this.desPic.Visible = true; } if (commentBLL.GetAllComments(_cardId).Count() != 0) { panel2.Visible = true; cmtNum.Text = commentBLL.GetAllComments(_cardId).Count().ToString(); } else { panel2.Visible = false; } if (cardInfoDTO.CountChecklist != 0) { this.checkList.Visible = true; this.checkList.Text = cardInfoDTO.CountCheckedlist + "/" + cardInfoDTO.CountChecklist; } else { this.checkList.Visible = false; } foreach (string name in listNameUser) { MemIcon member = new MemIcon(name, 25, 25); this.flowLayoutPanel2.Controls.Add(member); } }
private void CardEdit_Activated(object sender, EventArgs e) { cardInfoDTO = cardInfoBLL.CardInfo(_cardId); cardDTO = cardInfoDTO.Card; switch (cardDTO.Label) { case 1: this.CardLabel.BackColor = Color.Red; break; case 2: this.CardLabel.BackColor = Color.Yellow; break; case 3: this.CardLabel.BackColor = Color.Green; break; case 4: this.CardLabel.BackColor = Color.Orange; break; case 5: this.CardLabel.BackColor = Color.Blue; break; case 6: this.CardLabel.BackColor = Color.Fuchsia; break; default: this.CardLabel.BackColor = Color.Transparent; break; } this.cardName.Text = cardDTO.Title; this.dateTime.Text = cardDTO.DueDate.ToShortDateString(); if (cardDTO.Description == null || cardDTO.Description == "") { this.desPic.Visible = false; } else { this.desPic.Visible = true; } if (commentBLL.GetAllComments(_cardId).Count() != 0) { panel2.Visible = true; cmtNum.Text = commentBLL.GetAllComments(_cardId).Count().ToString(); } else { panel2.Visible = false; } if (cardInfoDTO.CountChecklist != 0) { this.checkList.Visible = true; this.checkList.Text = cardInfoDTO.CountCheckedlist + "/" + cardInfoDTO.CountChecklist; } else { this.checkList.Visible = false; } this.flowLayoutPanel2.Controls.Clear(); foreach (string name in listNameUser) { MemIcon member = new MemIcon(name); this.flowLayoutPanel2.Controls.Add(member); } }