public AccountSettingsModel GetListofAccountSettings(int id) { AccountSettingsModel accountsettings = new AccountSettingsModel(); string Query = "SELECT * FROM accountsettings WHERE CompId=" + id + ""; System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject()); while (dr.Read()) { accountsettings = new AccountSettingsModel(); accountsettings.Billbybilldetails = Convert.ToBoolean(dr["billbybilldetails"].ToString() == "1" ? true : false); accountsettings.creditlimits = Convert.ToBoolean(dr["creditlimits"].ToString() == "1" ? true : false); accountsettings.targets = Convert.ToBoolean(dr["targets"].ToString() == "1" ? true : false); accountsettings.costcenters = Convert.ToBoolean(dr["costcenters"].ToString() == "1" ? true : false); accountsettings.fbtreporting = Convert.ToBoolean(dr["fbtreporting"].ToString() == "1" ? true : false); accountsettings.bankreconcilations = Convert.ToBoolean(dr["bankreconcilations"].ToString() == "1" ? true : false); accountsettings.chequeprinting = Convert.ToBoolean(dr["chequeprinting"].ToString() == "1" ? true : false); //accountsettings.Billbybilldetails = Convert.ToBoolean(dr["billbybilldetails"].ToString()); //accountsettings.Billbybilldetails = Convert.ToBoolean(dr["billbybilldetails"].ToString()); } return(accountsettings); }
public virtual ActionResult Settings(AccountSettingsModel model) { using (var ts = new TransactionScope()) { _repository.ChangePassword(User.Identity.Name, model.Password); ts.Complete(); } return(RedirectToAction(MVC.Home.Index())); }
public AccountSettingsViewModel() { _currentUserAccount = new UserAccount(); _accountSettingsModel = new AccountSettingsModel(); _currentUserAccount.Username = "******"; _currentUserAccount.Email = "ThisShouldNotWorkAsAnEmail"; _currentUserAccount.Password = "******"; }
public async Task <IActionResult> SaveProfile(AccountSettingsModel model) { GetRoles(); if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(model.Email); _mapper.AccountSettingsModelToApplicationUser(model, user); if (!string.IsNullOrEmpty(model.OldPassword) || !string.IsNullOrEmpty(model.NewPassword) || !string.IsNullOrEmpty(model.NewPasswordConfirmation)) { if (string.IsNullOrEmpty(model.OldPassword)) { ModelState.AddModelError("OldPassword", "Enter your current password to change it"); return(View("Settings", model)); } if (string.IsNullOrEmpty(model.NewPassword)) { ModelState.AddModelError("NewPassword", "Enter your new password to change it"); return(View("Settings", model)); } var result = await _userManager.ChangePasswordAsync(user, model.OldPassword ?? "", model.NewPassword ?? ""); if (!result.Succeeded) { ModelState.AddModelError("OldPassword", "Incorrect password, please enter your current password to change it"); return(View("Settings", model)); } } var role = _roleManager.Roles.First(r => r.Id == model.RoleId).Name; var userRole = (await _userManager.GetRolesAsync(user)).FirstOrDefault(); if (role != userRole) { await _userManager.RemoveFromRoleAsync(user, userRole); await _userManager.AddToRoleAsync(user, role); } await _userManager.UpdateAsync(user); await HttpContext.RefreshLoginAsync(); if (User.IsInRole("Admin")) { return(RedirectToAction("Profile", new { userId = user.Id })); } return(RedirectToAction("Profile")); } return(View("Settings", model)); }
public void AccountSettingsModelToApplicationUser(AccountSettingsModel model, ApplicationUser user) { user.City = model.City; user.AddressLine1 = model.AddressLine1; user.AddressLine2 = model.AddressLine2; user.Country = model.Country; user.FirstName = model.FirstName; user.ImageUrl = model.ImageUrl; user.LastName = model.LastName; user.PhoneNumber = model.PhoneNumber; }
public void Accountsettings() { AccountSettingsModel lstSettings = objacbl.GetListofAccountSettings(2); if (lstSettings.Billbybilldetails) { //lblMaintainbillbybill.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; } if (lstSettings.chequeprinting) { lblChequePrinting.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; } }
public async Task <IActionResult> Settings() { User user = await _userManager.GetUserAsync(User); IList <LoginAttempt> logins = await Database.GetLoginAttemptsAsync(user.Id, 15, CancellationToken.None); AccountSettingsModel model = new AccountSettingsModel() { User = user, Logins = logins, }; return(View(model)); }
public void AccountSettingsWithInvalidModel() { var model = new AccountSettingsModel { Bio = new string('A', 161) }; var controller = new AccountController(); controller.ValidateModel(model); var result = controller.AccountSettings(model, null) as ViewResult; Assert.IsNotNull(result); Assert.AreEqual(string.Empty, result.ViewName); Assert.IsFalse(result.ViewData.ModelState.IsValid); }
public ActionResult AccountSettings() { var model = new AccountSettingsModel(); var user = Repository.FindUser(Security.CurrentUserId); if (user != null) { model.Account = user.Account; model.Name = user.Name; model.Website = user.Website; model.Location = user.Location; model.Bio = user.Bio; } return(View(model)); }
public static AccountSettingsModel Get(IServerAuthentication restClientAuthenticator) { var baseAddress = restClientAuthenticator.GetBaseAddress(); var authorizationToken = restClientAuthenticator.GetToken(); var tries = 0; var keepTrying = true; using (var restClient = new HttpClient()) { restClient.BaseAddress = new Uri(baseAddress); restClient.DefaultRequestHeaders.Accept.Clear(); restClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); while (keepTrying) { restClient.DefaultRequestHeaders.Add("Authorization", authorizationToken); HttpResponseMessage response = restClient.GetAsync(string.Format("api/{0}", ControllerName)).Result; if (response.StatusCode == HttpStatusCode.Unauthorized) { authorizationToken = restClientAuthenticator.GetToken(true); tries++; keepTrying = tries < 4; } else { keepTrying = false; if (response.IsSuccessStatusCode) { AccountSettingsModel accountSettingsModel = response.Content.ReadAsAsync <AccountSettingsModel>().Result; return(accountSettingsModel); } else { throw new HttpRequestException(string.Format(ApiClientGenericObjectResources.UnsuccessfulResponseMessage, response.StatusCode.ToString())); } } } throw new HttpRequestException(string.Format(ApiClientGenericObjectResources.UnsuccessfulResponseMessage, HttpStatusCode.Unauthorized.ToString())); } }
public static UserDifferenceAction GetComparingAction(ApplicationUserBaseModel userFromCookie, ApplicationUserBaseModel userFromDb, AccountSettingsModel accountSettings, RootSettings rightsSettings) { if (!userFromCookie.EmailConfirmed && userFromCookie.Email != rightsSettings.RootEmail && !accountSettings.IsLoginEnabledForUsersWhoDidNotConfirmEmail) { return(UserDifferenceAction.Logout); } if (userFromDb.DeActivated || userFromDb.PasswordHash != userFromCookie.PasswordHash) { return(UserDifferenceAction.Logout); } var compareResult = Compare(userFromCookie, userFromDb); return(!compareResult ? UserDifferenceAction.AutoReLogin : UserDifferenceAction.None); }
public ActionResult AccountSettings(AccountSettingsModel model, HttpPostedFileBase picture) { if (ModelState.IsValid) { try { byte[] image = null; if (picture != null && picture.ContentLength > 0) { image = new byte[picture.ContentLength]; picture.InputStream.Read(image, 0, image.Length); } var result = Repository.UpdateAccountSettings( Security.CurrentUserId, model.Name, model.Website, model.Location, model.Bio, image); if (result) { TempData["Notification"] = Strings.MsgAccountSettingsUpdated; } return(RedirectToAction("Index", "Account")); } catch { ModelState.AddModelError("", Strings.ErrorAccountSettingsUpdate); } } return(View(model)); }
public void AccountSettingsSuccessful() { var model = new AccountSettingsModel { Name = "john doe", Location = "country name", Website = "http://www.google.com", Bio = "some text" }; var image = new Mock <HttpPostedFileBase>(); var imageData = Encoding.UTF8.GetBytes("picture content"); image.Setup(mock => mock.ContentLength).Returns(imageData.Length); image.Setup(mock => mock.InputStream).Returns(new MemoryStream(imageData)); Security.Setup(mock => mock.CurrentUserId).Returns(1); Repository.Setup(mock => mock.UpdateAccountSettings( It.IsAny <int>(), // id It.IsAny <string>(), // name It.IsAny <string>(), // website It.IsAny <string>(), // location It.IsAny <string>(), // bio It.IsAny <byte[]>()) // image ).Returns(true); var controller = Controller.Object; var result = controller.AccountSettings(model, image.Object) as RedirectToRouteResult; Assert.IsNotNull(result); Assert.IsNotNull(controller.TempData["Notification"]); var routeValues = result.RouteValues; Assert.AreEqual("Index", routeValues["action"]); Assert.AreEqual("Account", routeValues["controller"]); }
private void btnSave_Click(object sender, EventArgs e) { AccountSettingsModel objmodel = new AccountSettingsModel(); objmodel.Billbybilldetails = chkBillbybill.Checked == true ? true:false; objmodel.creditlimits = chkCreditlimt.Checked == true ? true : false; objmodel.targets = chkTargets.Checked == true ? true : false; objmodel.costcenters = chkCostcenter.Checked == true ? true : false; objmodel.fbtreporting = chkFbtReport.Checked == true ? true : false; objmodel.bankreconcilations = chkBankRecon.Checked == true ? true : false; objmodel.postdatedcheques = chkPostdatedchq.Checked == true ? true : false; objmodel.saleswisemanbrokerwisereporting = chkSalesmanwiseRep.Checked == true ? true : false; objmodel.budgets = chkBudgets.Checked == true ? true : false; objmodel.royaltycalculation = chkRoylatyCal.Checked == true ? true : false; objmodel.companyactdepreciation = chkCompanyDesp.Checked == true ? true : false; objmodel.multicurrency = chkMultcurr.Checked == true ? true : false; objmodel.currencycondecimalplaces = tbxDecimalplaces.Text.Trim(); objmodel.maintainsubledgers = chkSubLedgers.Checked == true ? true : false; objmodel.postingaccountssalespurchasereturn = chkPostingAccounts.Checked == true ? true : false; objmodel.doubleentrysystemforpaymentreceiptvoucher = chkDoubleEntity.Checked == true ? true : false; objmodel.showaccountscurrentbalduringvoucher = chkCurrentBalance.Checked == true ? true : false; objmodel.maintainimagenotes = chkMaintainImages.Checked == true ? true : false; objmodel.balancesheetstockupdate = cbxBalanceStockupdate.SelectedItem.ToString(); objmodel.ledgerreconciliation = chkLedgerRecon.Checked == true ? true : false; objmodel.chequeprinting = chkChqPrinting.Checked == true ? true : false; objmodel.accountwiseinterstrate = chkAccountWiseInterest.Checked == true ? true : false; objmodel.enablepartydashboard = chkPartyDashboard.Checked == true ? true : false; objmodel.showpartydashboardselectingpartyvoucher = cbxSelectingParty.SelectedItem.ToString() == "Y" ? true : false; bool isscusses = objAccsBl.SaveAccountingSetting(objmodel); if (isscusses) { MessageBox.Show("Saved Scussfully"); } }
public static bool Save(IServerAuthentication restClientAuthenticator, AccountSettingsModel model) { return(ApiClientGenericObject <AccountSettingsModel> .Save(restClientAuthenticator, ControllerName, model)); }
public AccountSettingsViewModel(UserAccount currentUserAccount, AccountSettingsModel accountSettingsModel) { _currentUserAccount = currentUserAccount; _accountSettingsModel = accountSettingsModel; }