void button_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; Denominations DenomPopup = new Denominations(btn.Content.ToString()); DenomPopup.ShowDialog(); btn.Content = DenomPopup.Denom; var Selection = designerCanvas.SelectionService.CurrentSelection; ViewModelDesignerItem Ditem = new ViewModelDesignerItem(); foreach (var slc in Selection) { Ditem = (ViewModelDesignerItem)slc; } DockPanel Sourcepnl = (DockPanel)Ditem.Content; PropertyGrid SelectedPgrid = designerCanvas.TransactionList.Find(x => x.Id == Sourcepnl.Uid).PropertyGrid; string SelectedProperty = btn.Name.ToString(); string newValue = btn.Content.ToString(); StateCAS statecas = (StateCAS)SelectedPgrid.SelectedObject; Type ClassType = statecas.GetType(); PropertyInfo property = ClassType.GetProperty(SelectedProperty); property.SetValue(statecas, newValue, null); designerCanvas.TransactionList.Find(x => x.Id == Sourcepnl.Uid).PropertyGrid.SelectedObject = statecas; }
public ActionResult PayMoMo(int?id) { var coo = new FunctionsController(); var idus = coo.CookieID(); Denominations pakage = db.Denominations.Find(id); var money = pakage.denomination_price; //request params need to request to MoMo system string endpoint = "https://test-payment.momo.vn/gw_payment/transactionProcessor"; string partnerCode = "MOMO5RGX20191128"; string accessKey = "M8brj9K6E22vXoDB"; string serectkey = "nqQiVSgDMy809JoPF6OzP5OdBUB550Y4"; string orderInfo = "Nạp " + pakage.denomination_coin + " vào tài khoản " + idus.user_email; string returnUrl = "https://localhost:44365/Pays/ReturnUrl"; string notifyurl = "https://localhost:44365/Pays/NotifyUrl"; string amount = money; string orderid = Guid.NewGuid().ToString(); string requestId = Guid.NewGuid().ToString(); string extraData = ""; //Before sign HMAC SHA256 signature string rawHash = "partnerCode=" + partnerCode + "&accessKey=" + accessKey + "&requestId=" + requestId + "&amount=" + amount + "&orderId=" + orderid + "&orderInfo=" + orderInfo + "&returnUrl=" + returnUrl + "¬ifyUrl=" + notifyurl + "&extraData=" + extraData; MoMoSecurity crypto = new MoMoSecurity(); string signature = crypto.signSHA256(rawHash, serectkey); //build body json request JObject message = new JObject { { "partnerCode", partnerCode }, { "accessKey", accessKey }, { "requestId", requestId }, { "amount", amount }, { "orderId", orderid }, { "orderInfo", orderInfo }, { "returnUrl", returnUrl }, { "notifyUrl", notifyurl }, { "extraData", extraData }, { "requestType", "captureMoMoWallet" }, { "signature", signature } }; string responseFromMomo = PaymentRequest.sendPaymentRequest(endpoint, message.ToString()); JObject jmessage = JObject.Parse(responseFromMomo); Session["idpake"] = id; return(Redirect(jmessage.GetValue("payUrl").ToString())); }
/// <summary> /// Adds a Denomination to the currency's list. /// </summary> /// <param name="denom">The denomination to add.</param> public void AddDenomination(Denomination denom) { if (!Denominations.Contains(denom)) { Denominations.Add(denom); } }
public static void AddCoin(Denominations coin) { // Increment current coins SessionHelper.CurrentCoins[coin] = SessionHelper.CurrentCoins[coin] + 1; // Increment total coins SessionHelper.TotalCoins[coin] = SessionHelper.TotalCoins[coin] + 1; }
public ActionResult ReturnUrl(int errorCode, int amount) { var coo = new FunctionsController(); var id = coo.CookieID(); Users user = db.Users.Find(id.user_id); int idpake = int.Parse(Session["idpake"].ToString()); Denominations denominations = db.Denominations.Find(idpake); if (errorCode.Equals(0)) { user.user_coin = user.user_coins + int.Parse(denominations.denomination_coin.ToString()); db.SaveChanges(); Bills bills = new Bills { billdate = DateTime.Now, active = true, user_id = id.user_id, denomination_id = denominations.denomination_id, billdeadline = DateTime.Now }; db.Bills.Add(bills); db.SaveChanges(); return(RedirectToAction("History")); } else { Bills bills = new Bills { billdate = DateTime.Now, active = false, user_id = id.user_id, denomination_id = denominations.denomination_id, billdeadline = DateTime.Now }; db.Bills.Add(bills); db.SaveChanges(); return(RedirectToAction("History")); } }
/// <summary> /// Check usage for current denomination, add appropriate counts for denomination, and process the next lower denomination via recursion. /// </summary> /// <param name="change">Current change amounts</param> /// <param name="denominations">Denominations available</param> /// <returns></returns> public static ChangeAmounts Process(ChangeAmounts change, Denominations denominations) { var denominationAmount = denominations.changeDenominationValues[denominations.index]; // value of coin or bill. if (change.remaining >= denominationAmount) // If this denomination can be used. { int numberCoinsAllowed = (change.remaining / denominationAmount).ToInt(); #region randomize if (change.isRandom && denominations.index > 0) // Cannot randomize the lowest denomination. ie. pennies { numberCoinsAllowed = numberCoinsAllowed.RandomizeIntTo(); } #endregion change.numberCoins[denominations.index] = numberCoinsAllowed; change.remaining = change.remaining - (numberCoinsAllowed * denominationAmount); } if (denominations.index > 0 && change.remaining > 0) // continue recursion if change remains and if not the last denomination. ie. pennies { denominations.index--; // use the next denomination in list. Process(change, denominations); } return(change); }
public static void AddReturnCoin(Denominations coin) { // Increment return coins SessionHelper.ReturnCoins[coin] = SessionHelper.ReturnCoins[coin] + 1; }
/// <summary> /// Removes all denominations from the currency. /// </summary> public void ClearDenominations() { Denominations.Clear(); }