public IHttpActionResult PostSaveReceive(RecieveBitcoinViewModel obj) { if (con.State == ConnectionState.Open) { con.Close(); } con.Open(); SqlCommand cmd1 = new SqlCommand("SP_SaveReceive", con); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@UserId", obj.UserId); cmd1.Parameters.AddWithValue("@CoinTypeId", obj.CoinTypeId); cmd1.Parameters.AddWithValue("@QRCode", obj.QRCode); cmd1.Parameters.AddWithValue("@DestinationtoBitCoins", obj.DestinationBitcoin); cmd1.Parameters.AddWithValue("@Amount_In_USD", obj.AmtInUSD); cmd1.Parameters.AddWithValue("@Amount_In_Coins", obj.AmtInCoins); cmd1.Parameters.AddWithValue("@ReceivedTo", obj.RecievedToEmail); cmd1.Parameters.AddWithValue("@DescriptionTrans", obj.TrasactionDes); cmd1.Parameters.AddWithValue("@Insert_Date", System.DateTime.Now); int Result = cmd1.ExecuteNonQuery(); con.Close(); if (Result != 0) { return(Ok("Received Amount Saved Successfully")); } else { return(Ok("Record not saved , Try again..")); } }
public IHttpActionResult GetReceiveforUserId(Guid userid) { string str = "SELECT UserId,(select CoinName from tbl_Coin_Master where Id=CoinTypeId) as Coin_Name,QRCode,DestinationtoBitCoins,Amount_In_USD,Amount_In_Coins,ReceivedTo,DescriptionTrans,Insert_Date,Updated_Date FROM tbl_Coin_Receive where UserId='" + userid + "'"; SqlCommand cmd = new SqlCommand(str, con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); List <RecieveBitcoinViewModel> ls = new List <RecieveBitcoinViewModel>(); while (dr.Read()) { RecieveBitcoinViewModel ob = new RecieveBitcoinViewModel(); ob.UserId = dr[0].ToString(); ob.CoinName = (string)dr[1]; ob.QRCode = (string)dr[2]; ob.DestinationBitcoin = (string)dr[3]; ob.AmtInUSD = (decimal)dr[4]; ob.AmtInCoins = (decimal)dr[5]; ob.RecievedToEmail = (string)dr[6]; ob.TrasactionDes = (string)dr[7]; ob.InsertDate = (DateTime)dr[8]; if (dr[9] == DBNull.Value) { ob.UpdateDate = null; } else { ob.UpdateDate = (DateTime)dr[9]; } ls.Add(ob); } dr.Close(); con.Close(); //SqlDataAdapter da = new SqlDataAdapter(str, con); //DataSet ds = new DataSet(); //da.Fill(ds); //DataTable dt = new DataTable(); //dt = ds.Tables[0]; //con.Close(); //string jsonstring = JsonConvert.SerializeObject(dt); //return Ok(jsonstring); if (ls.Count == 0) { return(NotFound()); } return(Ok(ls)); }
// [ActionName("PostSaveReceive")] public ActionResult RecieveBitcoin(RecieveBitcoinViewModel obj) { // string CoinName = Request.Form["CoinTypeId"]; string CoinName = Request["CoinName"]; obj.QRCode = Request["Address"]; obj.DestinationBitcoin = "Sample"; 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; } return(View(obj)); } var userId = User.Identity.GetUserId(); obj.UserId = userId; // using (var scope = new TransactionScope()) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(url + "transaction/ReceiveaPost"); //HTTP POST var postTask = client.PostAsJsonAsync(url + "transaction/ReceiveaPost", obj); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { string message = "Hi, this " + Session["Email"] as string + " wants " + obj.AmtInCoins + " " + CoinName + " and Coin Address is " + Request["Address"]; SendMail.Mail(obj.RecievedToEmail, message); //return RedirectToAction("Index"); EmailNotification en = Session["Notification"] as EmailNotification; if (en != null) { if (en.Receive == true) { string uname = Session["UserName"] as string; string Email = Session["Email"] as string; string res = "Hi," + uname + " you sent Recieve coin requist. "; //SendMail a = new Blockchaninaccounts.App_Start.SendMail(); SendMail.Mail(Email, res); } } ViewBag.msg = "Receive Request successful...!"; 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(); return(View("DashboardSuccess")); } //else //{ // ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); //} } } ModelState.AddModelError(string.Empty, "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)); }