//public IHttpActionResult GetSaveExchange(Guid UserId, int CoinTypeId, decimal Amount_In_USD, decimal Amount_In_Coins, DateTime Updated_Date) public IHttpActionResult PostSaveExchange(ExchangeViewMode ex) { int Result = 0; if (con.State == ConnectionState.Open) { con.Close(); } con.Open(); SqlCommand cmd1 = new SqlCommand("SP_SaveExchange", con); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@UserId", ex.UserId); cmd1.Parameters.AddWithValue("@ExchangeCoinTypeId", ex.ExchangeCoinId); cmd1.Parameters.AddWithValue("@ReceiveCoinTypeId", ex.ReceiveCoinId); cmd1.Parameters.AddWithValue("@Amount_In_Ex", ex.AmtInEx); cmd1.Parameters.AddWithValue("@Amount_In_Re", ex.AmtInRe); cmd1.Parameters.AddWithValue("@Inserted_Date", System.DateTime.Now); try { Result = cmd1.ExecuteNonQuery(); } catch (Exception e) { throw e; } con.Close(); if (Result != 0) { return(Ok("Exchange Amount Saved Successfully")); } else { return(BadRequest("Record not saved , Try again..")); } }
public IHttpActionResult GetExchangeforUserId(Guid userid) { //(select CoinName from tbl_Coin_Master where Id = ReceiveCoinTypeId) as RecivCoin_Name string str = "select (select CoinName from tbl_Coin_Master where Id = ExchangeCoinTypeId) as ECoin_Name,(select CoinName from tbl_Coin_Master where Id = ReceiveCoinTypeId) as RCoin_Name,Amount_In_Exchange_Coin,Amount_In_Receive_Coin,InsertedDate from tbl_Coin_Exchange where UserId='" + userid + "'"; SqlCommand cmd = new SqlCommand(str, con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); List <ExchangeViewMode> ls = new List <ExchangeViewMode>(); while (dr.Read()) { ExchangeViewMode ob = new ExchangeViewMode(); ob.ECoinName = (string)dr[0]; ob.RCoinName = (string)dr[1]; ob.AmtInEx = (decimal)dr[2]; ob.AmtInRe = (decimal)dr[3]; if (dr[4] == DBNull.Value) { ob.Inserted_Date = null; } else { ob.Inserted_Date = (DateTime)dr[4]; } ls.Add(ob); } dr.Close(); con.Close(); if (ls.Count == 0) { return(NotFound()); } return(Ok(ls)); }
public ActionResult Exchange(ExchangeViewMode obj) { if (!ModelState.IsValid) { var d1 = CoinsMarketValueController.GetMarkupWithCoinId(); foreach (var r in d1) { switch (r.Key) { case 101: mark101 = r.Value; break; case 102: mark102 = r.Value; break; case 103: mark103 = r.Value; break; case 104: mark104 = r.Value; break; case 105: mark105 = r.Value; break; case 106: mark106 = r.Value; break; } } try { ViewBag.BTC = "$" + Math.Round((Convert.ToDecimal(objCoin.BTCCurrentPrice()) + Convert.ToDecimal(mark101)), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; } try { ViewBag.ETH = "$" + Math.Round((Convert.ToDecimal(objCoin.ETHCurrentPrice()) + Convert.ToDecimal(mark106)), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; } try { ViewBag.DASH = "$" + Math.Round((Convert.ToDecimal(objCoin.DASHCurrentPrice()) + Convert.ToDecimal(mark102)), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; } try { ViewBag.LTC = "$" + Math.Round((Convert.ToDecimal(objCoin.LTCCurrentPrice()) + Convert.ToDecimal(mark103)), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; } try { ViewBag.ETC = "$" + Math.Round((Convert.ToDecimal(objCoin.ETCCurrentPrice()) + Convert.ToDecimal(mark105)), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; } try { ViewBag.MBC = "$" + Math.Round((Convert.ToDecimal(objCoin.GetMBC_USDCoin()) + Convert.ToDecimal(mark104)), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; } ViewBag.Coinlist = Session["a"]; return(View(obj)); } var userId = User.Identity.GetUserId(); obj.UserId = userId; using (var client = new HttpClient()) { client.BaseAddress = new Uri(url + "Transaction/Exchange"); //HTTP POST var postTask = client.PostAsJsonAsync(url + "Transaction/Exchange", obj); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { EmailNotification en = (EmailNotification)Session["Notification"]; if (en != null) { if (en.Exchange == true) { string uname = Session["UserName"] as string; string Email = Session["Email"] as string; string res = "Hi," + uname + " you sent Exchange coin requist. "; //SendMail a = new Blockchaninaccounts.App_Start.SendMail(); SendMail.Mail(Email, res); } } var d2 = CoinsMarketValueController.GetMarkupWithCoinId(); foreach (var r in d2) { switch (r.Key) { case 101: mark101 = r.Value; break; case 102: mark102 = r.Value; break; case 103: mark103 = r.Value; break; case 104: mark104 = r.Value; break; case 105: mark105 = r.Value; break; case 106: mark106 = r.Value; break; } } try { ViewBag.BTC = "$" + Math.Round((Convert.ToDecimal(objCoin.BTCCurrentPrice()) + Convert.ToDecimal(mark101)), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; } try { ViewBag.ETH = "$" + Math.Round((Convert.ToDecimal(objCoin.ETHCurrentPrice()) + Convert.ToDecimal(mark106)), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; } try { ViewBag.DASH = "$" + Math.Round((Convert.ToDecimal(objCoin.DASHCurrentPrice()) + Convert.ToDecimal(mark102)), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; } try { ViewBag.LTC = "$" + Math.Round((Convert.ToDecimal(objCoin.LTCCurrentPrice()) + Convert.ToDecimal(mark103)), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; } try { ViewBag.ETC = "$" + Math.Round((Convert.ToDecimal(objCoin.ETCCurrentPrice()) + Convert.ToDecimal(mark105)), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; } try { ViewBag.MBC = "$" + Math.Round((Convert.ToDecimal(objCoin.GetMBC_USDCoin()) + Convert.ToDecimal(mark104)), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; } ModelState.Clear(); ViewBag.msg = "Exchange Amount Saved Successfully"; return(View("DashboardSuccess")); } //else if(result.ReasonPhrase=="400") //{ // ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); //} } ModelState.AddModelError(string.Empty, "Internal Server Error. Please contact administrator."); //ModelState.Clear(); ViewBag.Coinlist = Session["a"]; var d = CoinsMarketValueController.GetMarkupWithCoinId(); foreach (var r in d) { switch (r.Key) { case 101: mark101 = r.Value; break; case 102: mark102 = r.Value; break; case 103: mark103 = r.Value; break; case 104: mark104 = r.Value; break; case 105: mark105 = r.Value; break; case 106: mark106 = r.Value; break; } } try { ViewBag.BTC = "$" + Math.Round((Convert.ToDecimal(objCoin.BTCCurrentPrice()) + Convert.ToDecimal(mark101)), 2); } catch (Exception ex) { ViewBag.BTC = ex.Message; } try { ViewBag.ETH = "$" + Math.Round((Convert.ToDecimal(objCoin.ETHCurrentPrice()) + Convert.ToDecimal(mark106)), 2); } catch (Exception ex) { ViewBag.ETH = ex.Message; } try { ViewBag.DASH = "$" + Math.Round((Convert.ToDecimal(objCoin.DASHCurrentPrice()) + Convert.ToDecimal(mark102)), 2); } catch (Exception ex) { ViewBag.DASH = ex.Message; } try { ViewBag.LTC = "$" + Math.Round((Convert.ToDecimal(objCoin.LTCCurrentPrice()) + Convert.ToDecimal(mark103)), 2); } catch (Exception ex) { ViewBag.LTC = ex.Message; } try { ViewBag.ETC = "$" + Math.Round((Convert.ToDecimal(objCoin.ETCCurrentPrice()) + Convert.ToDecimal(mark105)), 2); } catch (Exception ex) { ViewBag.ETC = ex.Message; } try { ViewBag.MBC = "$" + Math.Round((Convert.ToDecimal(objCoin.GetMBC_USDCoin()) + Convert.ToDecimal(mark104)), 2); } catch (Exception ex) { ViewBag.MBC = ex.Message; } return(View(obj)); }