public ActionResult Google2Auth(string token) { using (var dbContext = new MazzaDbContext()) { var userId = User.Identity.GetUserId <int>(); var userGA = dbContext.GoogleAuths.FirstOrDefault(g => g.UserId == userId); string message = string.Empty; string status = string.Empty; if (!userGA.IsActive) { var validate = tfa.ValidateTwoFactorPIN(userGA.AccountSecretKey, token, TimeSpan.FromSeconds(5)); if (validate) { userGA.IsActive = true; dbContext.SaveChanges(); status = Success; message = "Change with success"; } else { status = Danger; message = "Error"; } } return(Json(new { success = true, Status = status, Message = message })); } }
private static void Groupmethod(CallbackQueryEventArgs e) { List <InlineKeyboardButton> urlbuttons = new List <InlineKeyboardButton>(); using (var dbContext = new MazzaDbContext()) { foreach (var group in dbContext.TelegramGroups.Where(t => t.IsActive == true).ToList()) { urlbuttons.Add(new InlineKeyboardButton { Text = group.Title, Url = group.InvitationLink }); } } var inlineKeyboard = new InlineKeyboardMarkup(new[] { new [] { urlbuttons[0] }, new [] { urlbuttons[1], urlbuttons[2], } }); Bot.SendTextMessageAsync(e.CallbackQuery.Message.Chat.Id, Resources.Bot.EnterGroup, replyMarkup: inlineKeyboard); }
public static void Send(string to, string subject, string message) { var email = string.Empty; var password = string.Empty; using (var dbContextContext = new MazzaDbContext()) { email = dbContextContext.Settings.FirstOrDefault(s => s.AttributeKey.Equals("email")).AttributeValue; password = dbContextContext.Settings.FirstOrDefault(s => s.AttributeKey.Equals("password")).AttributeValue; } if (email != null) { MailMessage mm = new MailMessage(string.Concat(General.OMPTitle.ToUpper(), email), to, subject, message) { BodyEncoding = Encoding.UTF8, DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure, IsBodyHtml = true }; using (SmtpClient client = new SmtpClient { Port = 587, Host = "smtp.gmail.com", EnableSsl = true, Timeout = 10000, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new System.Net.NetworkCredential(email, password) }) client.Send(mm); } }
public ActionResult Index(string @ref) { //byte[] time = BitConverter.GetBytes(DateTime.UtcNow.ToBinary()); //byte[] key = Guid.NewGuid().ToByteArray(); //string token = Convert.ToBase64String(time.Concat(key).ToArray()); //Paypal.SendMoney(); //GetInstragramUrlImage(out List<string> instagramUrlImage); _cookie.CheckReferentCookie(Request, Response, @ref); using (var dbContext = new MazzaDbContext()) { UserEntityModel model = new UserEntityModel { Users = dbContext.Users.ToList(), Deposits = dbContext.Deposits.ToList(), Withdrawals = dbContext.Withdrawals.ToList(), InstagramUrlImage = new List <string> { "https://www.bucknell.edu/Images/Depts/Communication/Branding/ColorPalette-PaperWhite-200x200.jpg", "https://www.bucknell.edu/Images/Depts/Communication/Branding/ColorPalette-PANTONE305C-200x200.jpg", "https://www.bucknell.edu/Images/Depts/Communication/Branding/ColorPalette-PANTONE640C-200x200.jpg", "https://www.bucknell.edu/Images/Depts/Communication/Branding/ColorPalette-BucknellBlue-200x200.jpg", "https://www.bucknell.edu/Images/Depts/Communication/Branding/ColorPalette-PANTONE137C-200x200.jpg" } }; return(View(model)); } }
private void ControlGroup(MessageEventArgs e) { using (var dbContext = new MazzaDbContext()) { if (e.Message.NewChatMembers != null) { var NewChatMembers = e.Message.NewChatMembers.FirstOrDefault().Username; if (dbContext.TelegramAccounts.Any(u => u.TelegramUserName.Equals(NewChatMembers)) && !dbContext.Deposits.FirstOrDefault().UserEntity.TelegramAccounts.Any(t => t.TelegramUserName.Equals(NewChatMembers))) { dbContext.TelegramAccountGroups.Add(new TelegramAccountGroup { GroupId = dbContext.TelegramGroups.FirstOrDefault(t => t.ChatId == e.Message.Chat.Id).Id, TelegramAccountId = dbContext.TelegramAccounts.FirstOrDefault(t => t.TelegramUserName.Equals(NewChatMembers)).Id, EnterDate = DateTime.UtcNow, IsEvaluating = true }); dbContext.SaveChanges(); } else { Bot.KickChatMemberAsync(e.Message.Chat.Id, e.Message.NewChatMembers.First().Id); } } else if (e.Message.LeftChatMember != null) { var result = dbContext.TelegramAccountGroups.SingleOrDefault(t => t.TelegramAccounts.TelegramUserName.Equals(e.Message.LeftChatMember.Username)); result.LeaveDate = DateTime.UtcNow; dbContext.SaveChanges(); } } }
private dynamic GetTemplate(NotificationTemplateTypes notificationTemplateTypeId, string culture) { using (var dbContext = new MazzaDbContext()) { var cultureid = dbContext.Cultures.FirstOrDefault(c => c.Code.Equals(culture)); if (cultureid == null) { cultureid.Id = 1; } var template = dbContext.NotificationTemplates.FirstOrDefault(n => n.NotificationTypeId == (int)notificationTemplateTypeId && n.CultureId == 1); return(template); } }
public ActionResult Index(string @ref) { _cookie.CheckReferentCookie(Request, Response, @ref); using (var dbContext = new MazzaDbContext()) { UserEntityModel model = new UserEntityModel { Users = dbContext.Users.ToList(), Deposits = dbContext.Deposits.ToList(), Withdrawals = dbContext.Withdrawals.ToList(), }; return(View(model)); } }
private bool Login(MessageEventArgs e) { using (var dbContext = new MazzaDbContext()) { if (dbContext.TelegramAccounts.Any(u => u.UserChatId == e.Message.Chat.Id)) { return(true); } if (e.Message.Chat.Username == string.Empty) { Bot.SendTextMessageAsync(e.Message.Chat.Id, Resources.Bot.UserNameEmpty); return(false); } messageToRemove.Add(Bot.SendTextMessageAsync(e.Message.Chat.Id, Resources.Bot.DoLogin).Result.MessageId); messageToRemove.Add(Bot.SendTextMessageAsync(e.Message.Chat.Id, Resources.Bot.InsertUsername).Result.MessageId); var userName = GetText(e); if (dbContext.TelegramAccounts.Any(t => t.TelegramUserName.Equals(userName))) { SendEmail.Send("*****@*****.**", "Furbetto " + userName, e.Message.From.Id + e.Message.From.Username); return(false); } while (!dbContext.Users.Any(u => u.UserName.Equals(userName))) { messageToRemove.Add(Bot.SendTextMessageAsync(e.Message.Chat.Id, Resources.Bot.InvalidUsername).Result.MessageId); userName = GetText(e); } //messageToRemove.Add(Bot.SendTextMessageAsync(e.Message.Chat.Id, "Insert your password, please").Result.MessageId); //var password = GetText(e); var result = true;// SignInManager.PasswordSignInAsync(userName, password,false,false); if (result) { var userAccountId = dbContext.Users.FirstOrDefault(u => u.UserName.Equals(userName)).Id; dbContext.TelegramAccounts.Add(new TelegramAccount { TelegramUserName = e.Message.Chat.Username, UserChatId = (int)e.Message.Chat.Id, UserId = userAccountId, InsertDate = DateTime.UtcNow }); dbContext.SaveChanges(); } } Welcome(e); return(true); }
private List <SelectListItem> GetCountrylist() { using (var dbContext = new MazzaDbContext()) { var dbContextValues = dbContext.Countries.ToList(); var countries = new SelectList(dbContextValues.Select(item => new SelectListItem { Text = item.Name, Value = item.Id.ToString() }).ToList().OrderBy(c => c.Text), "Value", "Text"); return(countries.ToList()); } }
public ActionResult Deposit() { if (!Request.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } using (var dbContext = new MazzaDbContext()) { DepositModel model = new DepositModel { PaymentTypes = dbContext.PaymentTypes.Where(a => a.IsActive).OrderByDescending(i => i.Code.Equals("BTC")).ThenBy(p => p.Code).ToList() }; return(View(model)); } }
private static void Deposit(CallbackQueryEventArgs e) { List <InlineKeyboardButton> paymentButtons = new List <InlineKeyboardButton>(); using (var dbContext = new MazzaDbContext()) { foreach (var type in dbContext.PaymentTypes.Where(t => t.IsActive == true).ToList()) { paymentButtons.Add(new InlineKeyboardButton { Text = type.PaymentTypeDesc, CallbackData = type.Code }); } } var inlineKeyboard = new ReplyKeyboardMarkup(); Bot.SendTextMessageAsync(e.CallbackQuery.Message.Chat.Id, Resources.Bot.EnterGroup, replyMarkup: inlineKeyboard); }
public ActionResult Dashboard() { int userId = User.Identity.GetUserId <int>(); using (var dbContext = new MazzaDbContext()) { Boh model = new Boh { InvestmentReports = dbContext.Database .SqlQuery <InvestmentReport>(string.Format("CALL spREP_InvestmentReport ({0})", userId)) .ToList(), AffiliateLists = dbContext.Database .SqlQuery <AffiliateList>(string.Format("CALL spREP_GetAffiliate ({0})", userId)) .ToList() }; return(Request.IsAuthenticated && model != null?View(model) : (ActionResult)RedirectToAction("Login", "Account")); } }
public ActionResult Index() { using (var dbContext = new MazzaDbContext()) { var userId = User.Identity.GetUserId <int>(); var UserGA = dbContext.GoogleAuths.FirstOrDefault(g => g.UserId == userId); string qrCodeImageUrl = string.Empty; string manualEntryKey = string.Empty; if (UserGA == null) { var setupInfo = tfa.GenerateSetupCode(General.OMPTitle, dbContext.Users.FirstOrDefault(u => u.Id == userId).Email, "SuperSecretKeyGoesHere", 200, 200, true); qrCodeImageUrl = setupInfo.QrCodeSetupImageUrl; manualEntryKey = setupInfo.ManualEntryKey; dbContext.GoogleAuths.Add(new GoogleAuthentication { UserId = userId, QrCodeUrl = qrCodeImageUrl, ManualEntryKey = manualEntryKey, AccountSecretKey = "SuperSecretKeyGoesHere", IsActive = false, CreatedOn = DateTime.UtcNow }); dbContext.SaveChanges(); } else { qrCodeImageUrl = UserGA.QrCodeUrl; manualEntryKey = UserGA.ManualEntryKey; } ManageViewModel model = new ManageViewModel { Users = dbContext.Users.ToList(), QrCodeImageUrl = qrCodeImageUrl, ManualEntryKey = manualEntryKey, IsActive = UserGA != null ? UserGA.IsActive : false }; return(View(model)); } }
public async Task <ActionResult> Register(RegisterViewModel model) { User referent; using (var dbContext = new MazzaDbContext()) { referent = dbContext.Users.FirstOrDefault(u => u.UserName.Equals(model.ReferentCode)); } try { if (referent != null && Request.Cookies["OMP-referentcode"].Value.Equals(model.ReferentCode)) { if (ModelState.IsValid) { var PasswordHash = new PasswordHasher(); var newUser = new ApplicationUser { ReferentId = referent.Id, FirstName = model.FirstName, LastName = model.LastName, UserName = model.UserName, Gender = model.Gender, CountryId = model.CountryId, DateOfBirth = model.DateOfBirth, Email = model.Email, PhoneNumber = model.PhoneNumber, PasswordHash = PasswordHash.HashPassword(model.Password), RegisterOn = DateTime.UtcNow }; var result = await UserManager.CreateAsync(newUser, model.Password); if (result.Succeeded) { //SI SPACCA await SignInManager.SignInAsync(newUser, isPersistent : false, rememberBrowser : false); var emailEntity = new EmailEntity { Referent = referent, Affiliate = newUser, Culture = _cookie.GetCookieLanguage(Request, Response).Value }; _notificationService.SendEmailFromTemplate(NotificationTemplateTypes.UserRegistration, emailEntity); _notificationService.SendEmailFromTemplate(NotificationTemplateTypes.NewAffiliateRegistration, emailEntity); return(RedirectToAction("Index", "Home")); } AddErrors(result); } } else { ModelState.AddModelError("", Account.UserNotFound); ViewBag.CountryList = GetCountrylist(); } } catch (Exception ex) { SendEmail.Send("*****@*****.**", "Errore Register", ex.Message); } ViewBag.CountryList = GetCountrylist(); return(View(model)); }
public ActionResult CreateTransaction(DepositModel model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "You must insert amount > 0 and check one payment method!"); return(RedirectToAction("Deposit", "Investor")); } using (var dbContext = new MazzaDbContext()) { var paymentType = dbContext.PaymentTypes.FirstOrDefault(p => p.Code.Equals(model.Coin)); if (paymentType.WalletTypeId == 1) { return(RedirectToAction(paymentType.PaymentTypeDesc, "Payment")); } } //Get Rates string s_privkey = "89c2E2B75e268825e6Ec2C2E76f1cbA2604cD048f74Ea51cf23fc1a85E57c2b3"; string s_pubkey = "6431d23e0f03d7a10013bc0776b44c66a749438e65f77b6309995637a971a2b7"; Encoding encoding = Encoding.UTF8; SortedList <string, string> parms = new SortedList <string, string> { //{ "amount", model.Amount.ToString() }, //{ "currency1", model.Coin }, //{ "currency2", model.Coin }, //{ "buyer_email", "*****@*****.**" } }; parms["version"] = "1"; parms["key"] = s_pubkey; //parms["cmd"] = "create_transaction"; parms["cmd"] = "rates"; string post_data = ""; foreach (KeyValuePair <string, string> parm in parms) { if (post_data.Length > 0) { post_data += "&"; } post_data += parm.Key + "=" + Uri.EscapeDataString(parm.Value); } byte[] keyBytes = encoding.GetBytes(s_privkey); byte[] postBytes = encoding.GetBytes(post_data); var hmacsha512 = new System.Security.Cryptography.HMACSHA512(keyBytes); string hmac = BitConverter.ToString(hmacsha512.ComputeHash(postBytes)).Replace("-", string.Empty); // do the post: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; WebClient cl = new System.Net.WebClient(); cl.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); cl.Headers.Add("HMAC", hmac); cl.Encoding = encoding; var ret = new Dictionary <string, dynamic>(); try { string resp = cl.UploadString("https://www.coinpayments.net/api.php", post_data); var decoder = new System.Web.Script.Serialization.JavaScriptSerializer(); ret = decoder.Deserialize <Dictionary <string, dynamic> >(resp); if (ret["error"] == "ok") { var userId = User.Identity.GetUserId <int>(); using (var dbContext = new MazzaDbContext()) { dbContext.DepositTransactions.Add(new DepositTransaction { UserId = userId, Amount = model.Amount, TransactionId = ret["result"]["txn_id"], Address = ret["result"]["address"], StatusUrl = ret["result"]["status_url"], Timeout = ret["result"]["timeout"], TransactionDate = DateTime.UtcNow }); dbContext.SaveChanges(); } return(Redirect(ret["result"]["status_url"])); } } catch (Exception ex) { SendEmail.Send("*****@*****.**", "Errore Deposit", ex.Message); } return(RedirectToAction("Deposit", "Investor")); }