void loadLists() { comboBox_RatioType.DataSource = UtilityExtension.EnumArray <RatioType>(); var bindingSource = agentGroupH.GetList(); comboBox_AgentGroupID.DataSource = bindingSource; comboBox_AgentGroupID.DisplayMember = "Value"; comboBox_AgentGroupID.ValueMember = "Key"; comboBox_AgentGroupID.SelectedValue = -1; var bindingSource2 = agentH.GetList(); comboBox_AgentID.DataSource = bindingSource2; comboBox_AgentID.DisplayMember = "Value"; comboBox_AgentID.ValueMember = "Key"; comboBox_AgentID.SelectedValue = -1; var bindingSource3 = agentH.GetList(AgentType.Chief); comboBox_AgentID_Chief.DataSource = bindingSource3; comboBox_AgentID_Chief.DisplayMember = "Value"; comboBox_AgentID_Chief.ValueMember = "Key"; comboBox_AgentID_Chief.SelectedValue = -1; var bindingSource4 = agentH.GetList(AgentType.Office); comboBox_AgentID_Office.DataSource = bindingSource4; comboBox_AgentID_Office.DisplayMember = "Value"; comboBox_AgentID_Office.ValueMember = "Key"; comboBox_AgentID_Office.SelectedValue = -1; }
void loadLists() { var bindingSource2 = aDealH.GetList(); comboBox_DealID.DataSource = bindingSource2; comboBox_DealID.DisplayMember = "Value"; comboBox_DealID.ValueMember = "Key"; comboBox_DealID.SelectedValue = -1; var bindingSource3 = aProductTransactionH.GetList(); comboBox_TransactionID.DataSource = bindingSource3; comboBox_TransactionID.DisplayMember = "Value"; comboBox_TransactionID.ValueMember = "Key"; comboBox_TransactionID.SelectedValue = -1; comboBox_DeductionAmountType.DataSource = UtilityExtension.EnumArray <DeductionType>(); comboBox_DeductionAmountType.SelectedIndex = 2; comboBox_CommissionRatioType.DataSource = UtilityExtension.EnumArray <RatioType>(); comboBox_CommissionRatioType.SelectedIndex = 1; comboBox_GroupCheck.DataSource = UtilityExtension.EnumArray <GroupType>(); comboBox_GroupCheck.SelectedIndex = 1; }
public ActionResult Index([Bind(Prefix = "id")] string username) { _dbContext = new ApplicationDbContext(); //Update the User Profile Details UserAccountService userAccountService = new UserAccountService(_dbContext); UserProfileVM userProfileVM = null; if (!string.IsNullOrEmpty(username)) { userProfileVM = userAccountService.GetUserProfile(username); } string currentUserId = ""; if (User.Identity.IsAuthenticated) { currentUserId = User.Identity.GetUserId(); } if (userProfileVM == null && User.Identity.IsAuthenticated) { userProfileVM = userAccountService.GetUserProfileById(currentUserId); } if (userProfileVM == null) { return(HttpNotFound()); } //Check whether the User is seeing his/her own Profile //If it is his/her ownn profile, return Edit Profile Page. //else return the Public Profile View ViewBag.HasUserFollowed = false; if (currentUserId.Equals(userProfileVM.Id)) { ViewBag.YearsOfBirth = UtilityExtension.GetYearsList(); ViewBag.LanguagesList = UtilityExtension.GetLanguagesList(); CurrencyService currencyService = new CurrencyService(_dbContext); ViewBag.CurrencyList = currencyService.GetAllCurrencies(); userProfileVM.ProfileImageData = userAccountService.GetUserProfileImageData(userProfileVM.Id); return(View("UpdateProfile", userProfileVM)); } else { if (User.Identity.IsAuthenticated) { ViewBag.HasUserFollowed = userAccountService.GetUserFollower(currentUserId, userProfileVM.Id) != null; } return(View("PublicProfile", userProfileVM)); } }
void loadLists() { var bindingSource = ContactH.GetList(); comboBox_ContactID.DataSource = bindingSource; comboBox_ContactID.DisplayMember = "Value"; comboBox_ContactID.ValueMember = "Key"; comboBox_ContactID.SelectedValue = -1; comboBox_ContributionRatioType.DataSource = UtilityExtension.EnumArray <RatioType>(); comboBox_CommissionRatioType.DataSource = UtilityExtension.EnumArray <RatioType>(); comboBox_SalaryRatioType.DataSource = UtilityExtension.EnumArray <RatioType>(); comboBox_AgentType.DataSource = UtilityExtension.EnumArray <AgentType>(); }
void loadLists() { comboBox_TransactionType.DataSource = UtilityExtension.EnumArray <ProductTransactionType>(); comboBox_TransactionType.SelectedIndex = 0; comboBox_AmountType.DataSource = UtilityExtension.EnumArray <AmountType>(); comboBox_AmountType.SelectedIndex = 0; comboBox_NextAmountType.DataSource = UtilityExtension.EnumArray <AmountType>(); comboBox_NextAmountType.SelectedIndex = 1; var bindingSource2 = aProductH.GetList(); comboBox_ProductID.DataSource = bindingSource2; comboBox_ProductID.DisplayMember = "Value"; comboBox_ProductID.ValueMember = "Key"; comboBox_ProductID.SelectedValue = -1; var bindingSource = aInvestmentGroupH.GetList(); comboBox_InvestmentGroupID.DataSource = bindingSource; comboBox_InvestmentGroupID.DisplayMember = "Value"; comboBox_InvestmentGroupID.ValueMember = "Key"; comboBox_InvestmentGroupID.SelectedValue = -1; var bindingSource3 = aAgentGroupH.GetList(); comboBox_AgentGroupID.DataSource = bindingSource3; comboBox_AgentGroupID.DisplayMember = "Value"; comboBox_AgentGroupID.ValueMember = "Key"; comboBox_AgentGroupID.SelectedValue = -1; var bindingSource5 = aDealH.GetList(); comboBox_DealID.DataSource = bindingSource5; comboBox_DealID.DisplayMember = "Value"; comboBox_DealID.ValueMember = "Key"; comboBox_DealID.SelectedValue = -1; var bindingSource4 = aContactH.GetList(); comboBox_PartyBID.DataSource = bindingSource4; comboBox_PartyBID.DisplayMember = "Value"; comboBox_PartyBID.ValueMember = "Key"; comboBox_PartyBID.SelectedValue = -1; }
void defaultValues() { textBox_Amount.Text = "0"; comboBox_TransactionType.DataSource = UtilityExtension.EnumArray <TransactionType>(); comboBox_TransactionType.SelectedIndex = 0; comboBox_WalletType.DataSource = UtilityExtension.EnumArray <WalletType>(); comboBox_WalletType.SelectedIndex = 0; comboBox_FlowType.DataSource = UtilityExtension.EnumArray <FlowType>(); comboBox_FlowType.SelectedIndex = 0; //comboBox5.SelectedIndex = 0; checkBox_CascadeChanges.Checked = true; }
private void SwitchCrack_CheckedChanged(object sender, EventArgs e) { if (SwitchCrack.Checked) { var tcpPort = UtilityExtension.GetValue(RegistryHive.LocalMachine, @"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "MaxUserPort", RegistryValueKind.DWord); if (string.IsNullOrWhiteSpace(tcpPort)) { if (UtilityExtension.SetValue(RegistryHive.LocalMachine, @"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "MaxUserPort", "60000", RegistryValueKind.DWord)) { lbCrack.Visible = true; lbCrack.Text = $"System cracked,Max Port Count for 60000"; MessageBox.Show("Crack Success!"); } } } }
private void MainForm_Load(object sender, EventArgs e) { BtnPauseRest(); btnStop.Enabled = false; var tcpPort = UtilityExtension.GetValue(RegistryHive.LocalMachine, @"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "MaxUserPort", RegistryValueKind.DWord); if (string.IsNullOrWhiteSpace(tcpPort)) { SwitchCrack.Enabled = true; SwitchCrack.Checked = false; } else { SwitchCrack.Enabled = false; SwitchCrack.Checked = true; lbCrack.Visible = true; lbCrack.Text = $"System cracked,Max Port Count for {tcpPort}"; } }
public ActionResult Step2() { ViewBag.DisableEmailTextbox = true; ViewBag.ShowResendEmailButton = false; _dbContext = new ApplicationDbContext(); //Get Current User's Profile string currentUserId = User.Identity.GetUserId(); UserAccountService userAccountService = new UserAccountService(_dbContext); UserProfileVM userProfileVM = userAccountService.GetUserProfileById(currentUserId); if (userProfileVM == null) { return(HttpNotFound()); } if (string.IsNullOrEmpty(userProfileVM.UrlUsername)) { userProfileVM.UrlUsername = User.Identity.GetExternalProviderUsername(); } if (string.IsNullOrEmpty(userProfileVM.Email) || userProfileVM.EmailConfirmed == false) { ViewBag.DisableEmailTextbox = false; } if (!string.IsNullOrEmpty(userProfileVM.Email)) { ViewBag.ShowResendEmailButton = true; } ViewBag.YearsOfBirth = UtilityExtension.GetYearsList(); ViewBag.LanguagesList = UtilityExtension.GetLanguagesList(); CurrencyService currencyService = new CurrencyService(_dbContext); ViewBag.CurrencyList = currencyService.GetAllCurrencies(); return(View(userProfileVM)); }
private async Task <ActionResult> CreateExternalProviderUserAsync(ExternalLoginInfo loginInfo) { //Create a New User and SignIn var user = new ApplicationUser(); //If External Provider has email, set the email here. Otherwise we will take it on Profile Wizard user.Email = loginInfo.Email; //If email is set, check whether a User with same email exists or not if (!string.IsNullOrEmpty(user.Email)) { if (UserManager.FindByEmail(user.Email) != null) { TempData["SignUpError"] = new IdentityResult(new List <string> { "Email is already taken", }); return(RedirectToAction("Index", "Home")); } //If an Email is returned from the Social Account, then Set the Email as Confirmed. //If an Email is no returned, we need to verify the Email first. user.EmailConfirmed = true; } string profilePictureUrl = null; //Check the Login Provider. We need to Extract the user data based on the LoginProvider switch (loginInfo.Login.LoginProvider) { case "Facebook": //Get Facebook User Data from the Saved Claim OAuthReponseUserFacebook facbookUserData = loginInfo.ExternalIdentity.GetOAuthUserData <OAuthReponseUserFacebook>(); if (facbookUserData != null) { //Save the Profile Image if (facbookUserData.Picture.Data != null) { if (!facbookUserData.Picture.Data.is_silhouette) { profilePictureUrl = facbookUserData.Picture.Data.URL; } } //Get the other Data user.FullName = facbookUserData.Name; user.UserName = "******" + facbookUserData.ID; } break; case "Google": //Get Google User Data from the Saved Claim OAuthReponseUserGoogle googleUserData = loginInfo.ExternalIdentity.GetOAuthUserData <OAuthReponseUserGoogle>(); if (googleUserData != null) { //Save the Profile Image if (googleUserData.Image != null) { if (!googleUserData.Image.IsDefault) { profilePictureUrl = googleUserData.Image.URL; } } //Get the other Data user.FullName = googleUserData.DisplayName; user.UserName = "******" + googleUserData.ID; } break; case "Instagram": //Get Google User Data from the Saved Claim OAuthReponseUserInstagram instagramUserData = loginInfo.ExternalIdentity.GetOAuthUserData <OAuthReponseUserInstagram>(); if (instagramUserData != null) { //Save the Profile Image profilePictureUrl = instagramUserData.ProfilePicture; //Get the other Data user.FullName = instagramUserData.FullName; user.UserName = "******" + instagramUserData.ID; } break; case "Twitter": //Get Google User Data from the Saved Claim OAuthReponseUserTwitter twitterUserData = loginInfo.ExternalIdentity.GetOAuthUserData <OAuthReponseUserTwitter>(); if (twitterUserData != null) { //Save the Profile Image if (!twitterUserData.DefaultProfileImage) { profilePictureUrl = twitterUserData.ProfileImageUrl; } //Get the other Data user.FullName = twitterUserData.Name; user.UserName = "******" + twitterUserData.ID; } break; } //Set the User Profile Create and Update Date user.CreatedOn = DateTime.UtcNow; user.UpdatedOn = DateTime.UtcNow; //Create a User var createUserResult = await UserManager.CreateAsync(user); if (createUserResult.Succeeded) { //Add User Roles UserManager.AddToRole(user.Id, _UserRolesType.User); //Add Login Infor based on the Login Provider createUserResult = await UserManager.AddLoginAsync(user.Id, loginInfo.Login); if (createUserResult.Succeeded) { //Download User Profile Image and Update User string profileImageName = DateTime.UtcNow.ToString("yyyyddmmhhmmss") + "_profile_original.jpg"; string profileImagePath = Server.MapPath("~" + _FileSavingPaths.ProfileImage + "/" + profileImageName); if (UtilityExtension.DownloadImage(profilePictureUrl, profileImagePath)) { user.ProfileImageOriginal = profileImageName; user.ProfileImageSelected = profileImageName; } await UserManager.UpdateAsync(user); //Add Provider Claim UserManager.AddClaim(user.Id, new Claim(_ClaimTypes.ExternalProviderType, loginInfo.Login.LoginProvider)); UserManager.AddClaim(user.Id, new Claim(_ClaimTypes.ExternalProviderUsername, loginInfo.DefaultUserName)); UserManager.AddClaim(user.Id, new Claim(_ClaimTypes.UrlUserName, loginInfo.DefaultUserName)); UserManager.AddClaim(user.Id, new Claim(_ClaimTypes.HasCompletedProfileWizard, false.ToString())); //Login the current User await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); //Add User Action Log new LogsSerivce().RunAddLogTask(_LogActionType.AccountCreated, user.Id, extraMessage: loginInfo.Login.LoginProvider); //TempData External Identity, After login, we will need some of these Claims TempData["ExternalLoginInfo"] = loginInfo.ExternalIdentity; //Add claims and Redirect to Profile Wizard Step 1 return(RedirectToAction("AddingClaims")); } } AddErrors(createUserResult); TempData["SignUpError"] = createUserResult; return(RedirectToAction("Index", "Home")); }
void defaultValues() { label_Add.Text = "0"; comboBox_Type.DataSource = UtilityExtension.EnumArray <EntityType>(); comboBox_Type.SelectedIndex = 0; }
public ActionResult UpdateProfile(UserProfileVM userProfileVM) { //If User does not exists, just update the UserData try { _dbContext = new ApplicationDbContext(); if (!ModelState.IsValid) { goto FormValidationFailed_GetData; } //Update the User Profile Details UserAccountService userAccountService = new UserAccountService(_dbContext); //Update the User userProfileVM.Id = User.Identity.GetUserId(); var userUpdateResponse = userAccountService.UpdateUserProfile(userProfileVM, false); if (userUpdateResponse.Success == false) { if (userUpdateResponse.MessageCode == ResponseResultMessageCode.EmailExists) { ModelState.AddModelError("Email", "A user already exists with the same email address. Please choose a different one."); ViewBag.DisableEmailTextbox = false; } else if (userUpdateResponse.MessageCode == ResponseResultMessageCode.UserNameExists) { ModelState.AddModelError("UrlUsername", "A user already exists with the same username. Please choose a different one."); } else { ModelState.AddModelError("", ResponseResultMessageCode.GetMessageFromCode(userUpdateResponse.MessageCode)); } goto FormValidationFailed_GetData; } //If User is Updated Successfully, Change UrlUserName Claim Also if (userUpdateResponse.SuccessCode == ResponseResultMessageCode.UserNameUpdated) { var owinContext = HttpContext.GetOwinContext(); var UserManager = owinContext.GetUserManager <ApplicationUserManager>(); //New Claims List, for current Identity List <Claim> newClaimsList = new List <Claim>(); Claim UserNameClaim = User.Identity.GetClaim(_ClaimTypes.UrlUserName); if (UserNameClaim != null) { //If the Username is changed, only then update the Claim if (!UserNameClaim.Value.ToLower().Equals(userProfileVM.UrlUsername.ToLower())) { UserManager.RemoveClaim(userProfileVM.Id, UserNameClaim); UserManager.AddClaim(userProfileVM.Id, new Claim(_ClaimTypes.UrlUserName, userProfileVM.UrlUsername)); newClaimsList.Add(new Claim(_ClaimTypes.UrlUserName, userProfileVM.UrlUsername)); } } else { UserManager.AddClaim(userProfileVM.Id, new Claim(_ClaimTypes.UrlUserName, userProfileVM.UrlUsername)); newClaimsList.Add(new Claim(_ClaimTypes.UrlUserName, userProfileVM.UrlUsername)); } //Update preferred language code if changed var preferredLangClaim = User.Identity.GetClaim(_ClaimTypes.PreferredLanguage); if (!preferredLangClaim.Value.ToLower().Equals(userProfileVM.PreferredLanguage)) { UserManager.RemoveClaim(userProfileVM.Id, preferredLangClaim); UserManager.AddClaim(userProfileVM.Id, new Claim(_ClaimTypes.PreferredLanguage, userProfileVM.PreferredLanguage)); newClaimsList.Add(new Claim(_ClaimTypes.PreferredLanguage, userProfileVM.PreferredLanguage)); } //Update Current Identity Claim and Login User Again if (newClaimsList.Count > 0) { User.Identity.AddOrUpdateClaims(newClaimsList, owinContext.Authentication); } } //User update was successfull #region Set user preferred language string userPreferredLanguageCode = "en"; if (User != null && User.Identity != null && User.Identity.GetClaim("PreferredLanguage") != null) { userPreferredLanguageCode = User.Identity.GetClaim("PreferredLanguage").Value; } #endregion //Now Check If Next button is clicked, goto Step 3 //If Back button is clicked, goto Step 1 return(RedirectToAction("Index", new { id = User.Identity.GetUrlUserName(), lang = userPreferredLanguageCode })); } catch (Exception err) { ModelState.AddModelError("", err); goto FormValidationFailed_GetData; } //Goto Statement If form validation is failed, goto View but first get the required data for View FormValidationFailed_GetData: ViewBag.YearsOfBirth = UtilityExtension.GetYearsList(); ViewBag.LanguagesList = UtilityExtension.GetLanguagesList(); CurrencyService currencyService = new CurrencyService(_dbContext); ViewBag.CurrencyList = currencyService.GetAllCurrencies(); return(View(userProfileVM)); }
public async Task <ActionResult> Step2(UserProfileVM userProfileVM, string SubmitAction = "") { //If User does no exists, just update the UserData try { ViewBag.DisableEmailTextbox = true; ViewBag.ShowResendEmailButton = false; _dbContext = new ApplicationDbContext(); bool skipValidation = false; //If Next Button is clicked, perform the Form Validation, otherwise do not perform Validations if (!SubmitAction.ToLower().Equals("back")) { if (!ModelState.IsValid) { goto FormValidationFailed_GetData; } } else { skipValidation = true; } //Update the User Profile Details UserAccountService userAccountService = new UserAccountService(_dbContext); //Check If the Username is unique userProfileVM.Id = User.Identity.GetUserId(); //Update the User var userUpdateResponse = userAccountService.UpdateUserProfile(userProfileVM, skipValidation); if (userUpdateResponse.Success == false) { if (userUpdateResponse.MessageCode == ResponseResultMessageCode.EmailExists) { ModelState.AddModelError("Email", "A user already exists with the same email address. Please choose a different one."); ViewBag.DisableEmailTextbox = false; } /*else if (userUpdateResponse.MessageCode == ResponseResultMessageCode.EmailNotConfirmed) * { * ModelState.AddModelError("Email", "You have not confirm your email address. Please confirm your email address to continue. Click on the \"Send Confirmation\" to send the confirmation link again."); * ViewBag.DisableEmailTextbox = false; * }*/ else if (userUpdateResponse.MessageCode == ResponseResultMessageCode.UserNameExists) { ModelState.AddModelError("UrlUsername", "A user already exists with the same username. Please choose a different one."); } else { ModelState.AddModelError("", ResponseResultMessageCode.GetMessageFromCode(userUpdateResponse.MessageCode)); } goto FormValidationFailed_GetData; } //If User is Updated Successfully, Change UrlUserName Claim Also var owinContext = HttpContext.GetOwinContext(); var UserManager = owinContext.GetUserManager <ApplicationUserManager>(); //New Claims List, for current Identity List <Claim> newClaimsList = new List <Claim>(); Claim UserNameClaim = User.Identity.GetClaim(_ClaimTypes.UrlUserName); if (UserNameClaim != null) { //If the Username is changed, only then update the Claim if (!UserNameClaim.Value.ToLower().Equals(userProfileVM.UrlUsername.ToLower())) { UserManager.RemoveClaim(userProfileVM.Id, UserNameClaim); UserManager.AddClaim(userProfileVM.Id, new Claim(_ClaimTypes.UrlUserName, userProfileVM.UrlUsername)); newClaimsList.Add(new Claim(_ClaimTypes.UrlUserName, userProfileVM.UrlUsername)); } } else { UserManager.AddClaim(userProfileVM.Id, new Claim(_ClaimTypes.UrlUserName, userProfileVM.UrlUsername)); newClaimsList.Add(new Claim(_ClaimTypes.UrlUserName, userProfileVM.UrlUsername)); } //If User is Updated then the Wizard is Completed, Change HasCompletedProfileWizard Claim Also Claim HasCompletedProfileWizardClaim = User.Identity.GetClaim(_ClaimTypes.HasCompletedProfileWizard); if (HasCompletedProfileWizardClaim != null) { UserManager.RemoveClaim(userProfileVM.Id, HasCompletedProfileWizardClaim); } UserManager.AddClaim(userProfileVM.Id, new Claim(_ClaimTypes.HasCompletedProfileWizard, true.ToString())); UserManager.AddClaim(userProfileVM.Id, new Claim(_ClaimTypes.PreferredLanguage, userProfileVM.PreferredLanguage)); newClaimsList.Add(new Claim(_ClaimTypes.HasCompletedProfileWizard, true.ToString())); newClaimsList.Add(new Claim(_ClaimTypes.PreferredLanguage, userProfileVM.PreferredLanguage)); //Update Current Identity Claim and Login User Again if (newClaimsList.Count > 0) { User.Identity.AddOrUpdateClaims(newClaimsList, owinContext.Authentication); } //User update was successfull //Now Check If Next button is clicked, goto Step 3 //If Back button is clicked, goto Step 1 if (SubmitAction.ToLower().Equals("back")) { return(RedirectToAction("Step1")); } else { //Before Redirecting to Step 3, send out an email confirmation link mail. if (userProfileVM.EmailConfirmed == false) { string code = await UserManager.GenerateEmailConfirmationTokenAsync(userProfileVM.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = userProfileVM.Id, code = code }, protocol: Request.Url.Scheme); string langCode = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; bool isSent = new EmailHelperService().SendEmailConfirmationTokenMail(userProfileVM.Email, callbackUrl, Strings.ConfirmationEmailSubject, langCode); TempData["ResponseResult"] = new ResponseResult <object> { Message = Strings.Step3_EmailConfirmationLinkText, Success = true }; } #region Set user preferred language string userPreferredLanguageCode = "en"; if (User != null && User.Identity != null && User.Identity.GetClaim("PreferredLanguage") != null) { userPreferredLanguageCode = User.Identity.GetClaim("PreferredLanguage").Value; } #endregion return(RedirectToAction("Step3", "Profile", new { lang = userPreferredLanguageCode })); } } catch (Exception err) { ModelState.AddModelError("", err); goto FormValidationFailed_GetData; } //Goto Statement If form validation is failed, goto View but first get the required data for View FormValidationFailed_GetData: ViewBag.YearsOfBirth = UtilityExtension.GetYearsList(); ViewBag.LanguagesList = UtilityExtension.GetLanguagesList(); CurrencyService currencyService = new CurrencyService(_dbContext); ViewBag.CurrencyList = currencyService.GetAllCurrencies(); return(View(userProfileVM)); }