public ActionResult phoneVerify() { try { if (Session["username"] != null) { AzureConnection db = new AzureConnection(); string username = Session["username"].ToString(); var data = db.user_table.Where(x => x.username == username).FirstOrDefault(); try { string code = Variables.sendSms(data.phone); Session["phoneCode"] = code; return(RedirectToAction("codePage")); } catch { ViewBag.Message = "Phone number isn't correct."; return(View()); } } return(View()); } catch { return(RedirectToAction("", "Home")); } }
public ActionResult user_info(string username) { AzureConnection db = new AzureConnection(); user_table user_data = db.user_table.Where(a => a.username == username).FirstOrDefault(); var trans_data = db.trans_history.Where(a => (a.seller == user_data.id || a.buyer == user_data.id)).ToArray(); ViewData["username"] = username; ViewData["star"] = 5; ViewData["rated_users"] = 30; ViewData["positive"] = 100; ViewData["no_trans"] = trans_data.Length; ViewData["btc"] = trans_data.Sum(x => x.btc) / trans_data.Length; if (ViewData["btc"].ToString() == "NaN") { ViewData["btc"] = 0; } ViewData["cash"] = trans_data.Sum(x => x.cash) / trans_data.Length; if (ViewData["cash"].ToString() == "NaN") { ViewData["cash"] = 0; } ViewData["country"] = (user_data.country == "gb" ? "UK": user_data.country).ToUpper(); ViewData["city"] = user_data.city; ViewData["avg"] = 2; return(View()); }
private async Task <string> SaveAzureDocumentBlob(string contentType, string fileName, string blobContainerName, Stream stream) { try { string fileFullPath = null; CloudStorageAccount cloudStorageAccount = AzureConnection.Get(); CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(blobContainerName); await cloudBlobContainer.CreateIfNotExistsAsync(); CloudBlockBlob cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference(fileName); //StorageCredentials creds = new StorageCredentials(AzureConnection.StorageAccountName, AzureConnection.StorageAccountAccessKey); //CloudBlockBlob cloudBlockBlob = new CloudBlockBlob(fileName, creds); cloudBlockBlob.Properties.ContentType = contentType; await cloudBlockBlob.UploadFromStreamAsync(stream); fileFullPath = cloudBlockBlob.Uri.ToString(); return(fileFullPath); }catch (Exception ex) { return(null); } }
public static void checkHoldBalance() { try { using (AzureConnection db = new AzureConnection()) { trans_history[] arr = db.trans_history.Where(a => a.holdBTC != true).ToArray(); foreach (trans_history v in arr) { string cur_balance = ApiHelper.BlockApi.getBalanceByAddress(v.holdWallet); // string cur_balance = ""+v.btc; if (double.Parse(cur_balance) >= v.btc) { v.holdBTC = true; v.holdTransID = "adfasdfasdfasdfasdf"; string body; string proceed_link = "http://trustbtc.azurewebsites.net/Contract/sentWire?transID=" + v.id; body = "Dear " + v.user_buyer.username + "<br/><br/>" + "We have received " + v.btc + "BTC" + " from user " + v.user_seller.username + ", and we hold them for you." + " To get them in your wallet you need to send a wire of $" + v.cash + " to:" + "<br/><br/>BENEFICIARY:" + v.firstname_seller + " " + v.lastname_seller + "<br/>IBAN:" + v.IBAN + "<br/>SWIFT:" + v.SWIFT + "<br/>REFERENCE:" + v.REFERENCE + " <br/><br/> After you have sent the wire, make sure to click below:<br/> <a href='" + proceed_link + "' class='btn btn-primary'>" + "I have sent wire </a>";; Variables.sendEmail(v.user_buyer.email, body); } v.holdAmount = double.Parse(cur_balance); db.SaveChanges(); } } } catch { } }
public ActionResult sendSmsCode() { try { string email = Session["email"].ToString(); AzureConnection db = new AzureConnection(); user_table v = db.user_table.Where(a => a.email == email).FirstOrDefault(); try { string code = Variables.sendSms(v.phone); Session["phoneCode"] = code; ViewData["step"] = "second"; ViewBag.Action = "google_auth"; return(View("google_auth")); } catch { ViewBag.Message = "Phone number isn't correct."; ViewData["step"] = "first"; ViewBag.Action = "google_auth"; return(View("google_auth")); } } catch { return(RedirectToAction("", "Home")); } }
public ActionResult buyTransPage(string id) { try { if (id == null) { id = Session["transID"].ToString(); } Session["transID"] = id; AzureConnection db = new AzureConnection(); trans_history trans_data = db.trans_history.Where(a => a.id.ToString() == id).FirstOrDefault(); ViewData["btc_amount"] = trans_data.btc; ViewData["sellerName"] = trans_data.user_seller.username; ViewData["cash"] = trans_data.cash; ViewData["walletID"] = trans_data.buyerWallet == null ? "" : trans_data.buyerWallet; ViewData["transID"] = trans_data.id; if (trans_data.buyTime == null) { trans_data.buyTime = DateTime.UtcNow; db.SaveChanges(); ViewData["buyTime"] = 0; return(View()); } else { TimeSpan diff = (TimeSpan)(DateTime.UtcNow - trans_data.buyTime); ViewData["buyTime"] = diff.TotalSeconds; return(View()); } } catch { return(RedirectToAction("", "Home")); } }
public MainWindow() { AzureConnection.GetInstance().CreateQueue("messages"); InitializeComponent(); this.DataContext = this; RunMessageFetcher(); }
public JsonResult validateQRCode(string qrCode) { try { TwoFactorAuthenticator tfa = new TwoFactorAuthenticator(); AzureConnection db = new AzureConnection(); string email = Session["email"].ToString(); var user_data = db.user_table.Where(a => a.email == email).FirstOrDefault(); var result = tfa.ValidateTwoFactorPIN(user_data.qrkey, qrCode); result = true; if (result) { user_data.qrScanned = true; db.SaveChanges(); return(Json("success", JsonRequestBehavior.AllowGet)); } else { return(Json("failed", JsonRequestBehavior.AllowGet)); } } catch { return(Json("failed", JsonRequestBehavior.AllowGet)); } }
public bool userExist(UserSignupPage data) { AzureConnection db = new AzureConnection(); var v = db.user_table.Where(a => a.email == data.email || a.username == data.username).FirstOrDefault(); return(v != null); }
public void Post(string message) { CloudQueue queue = AzureConnection.GetInstance().CloudQueue; CloudQueueMessage queueMessage = new CloudQueueMessage(message); queue.AddMessage(queueMessage); }
public ActionResult validateSms(string phoneCode) { try { if (Session["phoneCode"].ToString() == phoneCode) { ViewData["step"] = "third"; ViewBag.Action = "google_auth"; AzureConnection db = new AzureConnection(); string email = Session["email"].ToString(); var user_data = db.user_table.Where(a => a.email == email).FirstOrDefault(); user_data.qrScanned = true; db.SaveChanges(); TwoFactorAuthenticator tfa = new TwoFactorAuthenticator(); SetupCode setupInfo = tfa.GenerateSetupCode("TRUSTBTC", Session["email"].ToString(), Session["qrkey"].ToString(), 300, 300); ViewData["qrUrl"] = setupInfo.QrCodeSetupImageUrl; return(View("google_auth")); } else { ViewData["step"] = "second"; ViewBag.Action = "google_auth"; ViewBag.Message = "Code isn't correct."; return(View("google_auth")); } } catch { return(RedirectToAction("", "Home")); } }
public ActionResult saveMylisting() { try { string email = Session["email"].ToString(); AzureConnection db = new AzureConnection(); user_table v = db.user_table.Where(a => a.email == email).FirstOrDefault(); v.check_btc = Request.Form["check_btc"] == null ? false : true; v.btc_cash = Request.Form["btc_cash"] == null ? false : true; v.btc_cash_com = double.Parse(Request.Form["btc_cash_com"]); v.btc_wire = Request.Form["btc_wire"] == null ? false : true; v.btc_wire_com = double.Parse(Request.Form["btc_wire_com"]); v.check_eth = Request.Form["check_eth"] == null ? false : true; v.eth_cash = Request.Form["eth_cash"] == null ? false : true; v.eth_cash_com = double.Parse(Request.Form["eth_cash_com"]); v.eth_wire = Request.Form["eth_wire"] == null ? false : true; v.eth_wire_com = double.Parse(Request.Form["eth_wire_com"]); v.from_cash = double.Parse(Request.Form["from_cash"]); v.to_cash = double.Parse(Request.Form["to_cash"]); v.city = Request.Form["city"]; v.country = Request.Form["country"]; v.listme = Request.Form["listme"] == null ? false : true; db.SaveChanges(); return(RedirectToAction("mylistings")); } catch { return(RedirectToAction("", "Home")); } }
public static string ToggleVM([ActivityTrigger] string key) { //return Toggle(key); var machine = new AzureConnection("4bc6eea4-c3ed-4346-84a8-18f6868195ac", "9e497778-66dd-4947-828e-720f6595ff69", "=RST6396Q_h_rodQR]Lj7O86pckrc.-z").ToggleMachineState(key); return(machine); }
public void UploadTestFile() { string containerName = "TestContainer"; string blockBlogName = "Test.txt"; AzureConnection azureService = new AzureConnection(); // Notice the Request.Files instead of localFileName azureService.UploadFileToBlobStorage(containerName, blockBlogName, Request.Files); }
public ActionResult bankDetail() { string transID = Session["transID"].ToString(); AzureConnection db = new AzureConnection(); trans_history trans_data = db.trans_history.Where(a => a.id.ToString() == transID).FirstOrDefault(); ViewData["REFERENCE"] = trans_data.REFERENCE; return(View()); }
public JsonResult getBalance() { string cur_balance; string transID = Session["transID"].ToString(); AzureConnection db = new AzureConnection(); trans_history trans_data = db.trans_history.Where(a => a.id.ToString() == transID).FirstOrDefault(); cur_balance = "" + trans_data.holdAmount; return(Json(cur_balance, JsonRequestBehavior.AllowGet)); }
public JsonResult isBTCHolded() { string transID = Session["transID"].ToString(); AzureConnection db = new AzureConnection(); trans_history trans_data = db.trans_history.Where(a => a.id.ToString() == transID).FirstOrDefault(); if (trans_data.holdBTC == true) { return(Json("success", JsonRequestBehavior.AllowGet)); } return(Json("failed", JsonRequestBehavior.AllowGet)); }
public string Get() { CloudQueue queue = AzureConnection.GetInstance().CloudQueue; CloudQueueMessage retrievedMessage = queue.GetMessage(); if (retrievedMessage != null) { string message = retrievedMessage.AsString; queue.DeleteMessage(retrievedMessage); return(message); } return(null); }
public ActionResult uploadRecipt(HttpPostedFileBase file) { try { string transID = Session["transID"].ToString(); if (file == null) { return(View("uploadReciptPage")); } AzureConnection db = new AzureConnection(); trans_history trans_data = db.trans_history.Where(a => a.id.ToString() == transID).FirstOrDefault(); if (Session["uploadType"].ToString() == "recieve") { trans_data.recieveCash = true; trans_data.sentBTC = true; trans_data.status = "complete"; db.SaveChanges(); ApiHelper.BlockApi.withDrawByAddress(trans_data.holdWallet, trans_data.buyerWallet, (trans_data.btc - 0.00011795).ToString()); string body; body = "Dear " + trans_data.user_buyer.username + "<br/><br/>" + " We have just sent to your wallet, " + (trans_data.btc - 0.00011795) + " BTC (0.00011795 BTC is transaction fee). Transaction completed with user " + trans_data.user_seller.username + "<br/>Thank you"; Variables.sendEmail(trans_data.user_buyer.email, body); string path = System.IO.Path.Combine(Server.MapPath("~/Uploads/"), "receive" + transID + ".png"); file.SaveAs(path); return(RedirectToAction("", "Home")); } else if (Session["uploadType"].ToString() == "sent") { trans_data.sentCash = true; db.SaveChanges(); string body; string link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "/Contract/recievedWire?transID=" + trans_data.id); body = "Dear " + trans_data.user_seller.username + "<br/><br/>" + "User " + trans_data.user_buyer.username + " has just notified us that the wire of $" + trans_data.cash + " has been sent to your bank account ending in " + trans_data.IBAN.Substring(trans_data.IBAN.Length - 4) + ". Please look your bank account as it will reach very soon. You need to confirm receipt by pressing the button below, after receiving the funds." + "<br/><br/><a href='" + link + "' class='btn btn-primary'>" + "I have receipt the wire.Thank you</a>";; Variables.sendEmail(trans_data.user_seller.email, body); string path = System.IO.Path.Combine(Server.MapPath("~/Uploads/"), "sent" + transID + ".png"); file.SaveAs(path); return(RedirectToAction("", "Home")); } else { return(RedirectToAction("", "Home")); } } catch { return(RedirectToAction("", "Home")); } }
public IEnumerable <VirtualMachineHelper> Get() { var conn = new AzureConnection("11c4bafa-00bb-43f4-a42d-ed6f2663fbaf", "92c95553-455f-4b53-8bcf-e2dfe4dbcb0b", "A4LbQRKmqT:2x4Iu/h=yM=pDBuu9VVA1"); var GetMachines = conn.VirtualMachines; //var GetMachines = new AzureConnection("4bc6eea4-c3ed-4346-84a8-18f6868195ac", // "9e497778-66dd-4947-828e-720f6595ff69", // "=RST6396Q_h_rodQR]Lj7O86pckrc.-z").VirtualMachines; return(GetMachines); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(options => { options.Authority = $"https://{Configuration["Auth0:Domain"]}/"; options.Audience = Configuration["Auth0:Audience"]; }); services.AddControllers(); AzureConnection.CreateConnections(Configuration.GetValue <string>(key: "AzureBlobStorage")); }
public static string ToggleVM([ActivityTrigger] string[] args, ILogger log) { //return Toggle(key); var machine = new AzureConnection("11c4bafa-00bb-43f4-a42d-ed6f2663fbaf", "92c95553-455f-4b53-8bcf-e2dfe4dbcb0b", "A4LbQRKmqT:2x4Iu/h=yM=pDBuu9VVA1", log).ToggleMachineState(args); //var machine = new AzureConnection("4bc6eea4-c3ed-4346-84a8-18f6868195ac", // "9e497778-66dd-4947-828e-720f6595ff69", // "=RST6396Q_h_rodQR]Lj7O86pckrc.-z", // log).ToggleMachineState(key); return(machine); }
public ActionResult mybank() { try { string email = Session["email"].ToString(); AzureConnection db = new AzureConnection(); user_table v = db.user_table.Where(a => a.email == email).FirstOrDefault(); ViewBag.Action = "mybank"; return(View(v)); } catch { return(RedirectToAction("", "Home")); } }
public ActionResult status() { try { AzureConnection db = new AzureConnection(); string email = Session["email"].ToString(); var v = db.trans_history.Where(a => (a.user_buyer.email == email || a.user_seller.email == email) && a.status == "pending").ToArray(); ViewData["trans"] = v; return(View()); } catch { return(RedirectToAction("", "Home")); } }
public ActionResult Registeration(UserSignupPage data) { bool Status = false; string message = ""; ViewData["phoneNumber"] = Session["phoneNumber"].ToString(); try { var IsExist = userExist(data); if (IsExist) { message = "Email or username already exists"; } else { AzureConnection db = new AzureConnection(); user_table tbdata = new user_table(); tbdata.firstname = data.firstname; tbdata.lastname = data.lastname; tbdata.username = data.username; tbdata.email = data.email; tbdata.phone = Session["phoneNumber"].ToString(); tbdata.country = Session["countryCode"].ToString(); tbdata.phoneVerified = false; tbdata.kycVerified = false; tbdata.password = data.password; tbdata.emailVerified = false; tbdata.qrkey = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10); tbdata.signup = DateTime.UtcNow; tbdata.listme = false; tbdata.qrScanned = false; tbdata.emailCode = Guid.NewGuid(); SendVerificationLinkEmail(tbdata); message = "Activate your email to complete your setup. We have sent activation link to your email: " + data.email; Status = true; db.user_table.Add(tbdata); db.SaveChanges(); } } catch (Exception ex) { message = ex.Message; } ViewBag.Message = message; ViewBag.Status = Status; return(View(data)); }
public ActionResult googleAuthPage() { try { AzureConnection db = new AzureConnection(); string email = Session["email"].ToString(); var user_data = db.user_table.Where(a => a.email == email).FirstOrDefault(); TwoFactorAuthenticator tfa = new TwoFactorAuthenticator(); SetupCode setupInfo = tfa.GenerateSetupCode("TRUSTBTC", Session["email"].ToString(), Session["qrkey"].ToString(), 200, 200); ViewData["qrUrl"] = setupInfo.QrCodeSetupImageUrl; ViewBag.scanned = user_data.qrScanned; return(View()); } catch { return(RedirectToAction("", "Home")); } }
public JsonResult saveWalletID(string walletID) { var isValid = BlockApi.validateAddress(walletID); if (isValid == false) { return(Json("failed", JsonRequestBehavior.AllowGet)); } string transID = Session["transID"].ToString(); AzureConnection db = new AzureConnection(); trans_history trans_data = db.trans_history.Where(a => a.id.ToString() == transID).FirstOrDefault(); trans_data.buyerWallet = walletID; Session["buyerWallet"] = walletID; db.SaveChanges(); return(Json("success", JsonRequestBehavior.AllowGet)); }
public ActionResult Login(UserLoginPage data) { string message = ""; try { AzureConnection db = new AzureConnection(); var result = db.user_table.Where(x => x.email == data.EmailID && x.password == data.Password).FirstOrDefault(); if (result == null) { message = "Invalid credential provided"; } else { if (result.emailVerified == false) { message = "Your account is not verified!"; } else { Session["username"] = result.username; Session["email"] = result.email; Session["qrkey"] = result.qrkey; if (Session["next_url"] == null) { return(RedirectToAction("", "Home")); } else if (Session["user_type"] != null) { return(Redirect(Session["next_url"].ToString())); } else { return(RedirectToAction("", "Home")); } } } } catch { message = "Database connection failed!"; } ViewBag.Message = message; return(View(data)); }
public async Task <string> DeleteDocumentLibraryDocumentsAsync(string documentLibraryId, bool alsoDeleteDocLib) { // delete the container and all files underneath it for the specified document library string blobContainerName = _SharePointDocLibPrefix; try { // NOTE: Azure Blob container names must be all lowercase and cannot start with numbers if (documentLibraryId != null) { blobContainerName += documentLibraryId; } CloudStorageAccount cloudStorageAccount = AzureConnection.Get(); CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(blobContainerName); if (alsoDeleteDocLib == true) { // Deleting the container will also delete all underlying files in container await cloudBlobContainer.DeleteIfExistsAsync(); } else { // Delete all underlying files in container foreach (IListBlobItem item in cloudBlobContainer.ListBlobs(null, false)) { if (item.GetType() == typeof(CloudBlockBlob)) { CloudBlockBlob blob = (CloudBlockBlob)item; await blob.DeleteIfExistsAsync(); } } } return(null); } catch (Exception ex) { // TODO: log this exception and bubble up to the interface?? return(ex.Message); } }
public ActionResult proceed(int userID, int transID) { try { AzureConnection db = new AzureConnection(); trans_history data = db.trans_history.Where(a => a.id == transID).FirstOrDefault(); Session["transID"] = transID; Session["btc_amount"] = data.btc; Session["cash"] = data.cash; Session["buyerEmail"] = data.user_buyer.email; Session["buyerName"] = data.user_buyer.username; Session["sellerEmail"] = data.user_seller.email; Session["sellerName"] = data.user_seller.username; Session["holdWallet"] = data.holdWallet; Session["user_type"] = userID == data.buyer ? "old_buyer": "old_seller"; db.SaveChanges(); if (Session["username"] == null) { if (double.Parse(Session["cash"].ToString()) >= 1000 && data.user_seller.kycVerified == false) { Session["isCreater"] = "no"; Session["next_url"] = "/Verify/IdVerify"; } else { Session["next_url"] = userID == data.buyer ? "/Contract/buyTransPage" : "/Contract/bankDetail"; } return(RedirectToAction("Login", "User_Login")); } else { if (double.Parse(Session["cash"].ToString()) >= 1000 && data.user_seller.kycVerified == false) { return(RedirectToAction("IdVerify", "Verify")); } return(userID == data.buyer ? RedirectToAction("buyTransPage") :RedirectToAction("bankDetail")); } } catch { return(RedirectToAction("", "Home")); } }