public ActionResult AccountDetails(AccountDetailsModel userModel) { if (WorkContext.CurrentUserId == 0) { return(RedirectToAction("LogOff", "Account", new { ReturnUrl = Request.RawUrl })); } if (ModelState.IsValid && userModel.UserId > 0) { var entityUpdate = _userRepository.GetById(userModel.UserId); entityUpdate.Address1 = userModel.Address1; entityUpdate.Address2 = userModel.Address2; entityUpdate.FirstName = userModel.ContactName; entityUpdate.ContactNumber = userModel.ContactNumber; entityUpdate.CountryRegion = userModel.CountryRegion; entityUpdate.EmailAddress = userModel.EmailAddress; entityUpdate.PostCodeZip = userModel.PostCodeZip; entityUpdate.TownCity = userModel.TownCity; using (UnitOfWork) { var modelEdit = _userRepository.Update(entityUpdate); } } //Get list country var listCountry = CountryList.GetCountryList("US"); ViewBag.ListCountry = listCountry; return(View(userModel)); }
public ActionResult AccountDetails() { if (WorkContext.CurrentUserId == 0) { return(RedirectToAction("LogOff", "Account", new { ReturnUrl = Request.RawUrl })); } var entity = _userRepository.GetById(WorkContext.CurrentUserId); var model = new AccountDetailsModel { UserId = entity.UserId, Address1 = entity.Address1, Address2 = entity.Address2, CompanyName = entity.CompanyName, ContactName = entity.FirstName, ContactNumber = entity.ContactNumber, CountryRegion = entity.CountryRegion, EmailAddress = entity.EmailAddress, PostCodeZip = entity.PostCodeZip, TownCity = entity.TownCity, Password = entity.Password, ConfirmPassword = entity.Password, }; //Get list country var listCountry = CountryList.GetCountryList("US"); ViewBag.ListCountry = listCountry; return(View(model)); }
public async Task <ActionMessage> UpdateAsync(AccountDetailsModel model, List <IFormFile> userImage) { ActionMessage response = new ActionMessage(); User user = await userManager.FindByIdAsync(model.UserId); bool exists = userManager.Users.Where(x => x.Id != model.UserId && x.UserName == model.UserName).Any(); if (exists) { response.Error = $"Update Failed!!! Username {model.UserName} aleready exists "; return(response); } byte[] image = await ByteArrayConverter.ConvertImageToByteArrayAsync(userImage); if (user != null) { user.Email = model.Email; user.UserName = model.UserName; user.UserImage = image; IdentityResult result = await userManager.UpdateAsync(user); if (result.Succeeded) { response.Message = "Update Successful"; } } else { response.Error = "Update Failed"; } return(response); }
public void Standard(RegisterOutput output) { var transactions = new List <TransactionModel>(); foreach (var item in output.Account.Transactions) { var transaction = new TransactionModel( item.Amount, item.Description, item.TransactionDate); transactions.Add(transaction); } var account = new AccountDetailsModel( output.Account.AccountId, output.Account.CurrentBalance, transactions); var accounts = new List <AccountDetailsModel>(); accounts.Add(account); var registerResponse = new RegisterResponse( output.Customer.CustomerId, output.Customer.SSN, output.Customer.Name, accounts); this.ViewModel = new CreatedAtRouteResult( "GetCustomer", new { customerId = registerResponse.CustomerId, version = "1.0" }, registerResponse); }
public ActionResult AccountDetails() { Employee employee; Customer customer; AccountDetailsModel model = new AccountDetailsModel(); string type; if (Session["EmployeeId"] != null) { int id = (int)Session["EmployeeId"]; using (NorthwindConnection db = new NorthwindConnection()) { employee = db.Employees.SingleOrDefault(p => p.EmployeeID == id); } type = "employee"; model.Employee = employee; } else { string id = (string)Session["CustomerId"]; using (NorthwindConnection db = new NorthwindConnection()) { customer = db.Customers.SingleOrDefault(c => c.CustomerID == id); } model.Customer = customer; type = "customer"; } model.UserType = type; return(View(model)); }
public async Task <bool> UpdateAccount(AccountDetailsModel model, BankDetail bankDetail) { try { //Confirm the existence of the account number var checkAccountNumber = await _accountManager.ExistsAccount(model.AccountNumber, model.ID); if (checkAccountNumber) { throw new AccountDetailsAlreadyExistException($"Account number { model.AccountNumber } already exist"); } AccountDetail accountDetails = await _accountManager.GetAccountById(model.ID); _log.Warn($"Old account details::: {JsonConvert.SerializeObject(accountDetails)}"); accountDetails.Id = model.ID; accountDetails.AccountName = model.AccountName; accountDetails.AccountNumber = model.AccountNumber; accountDetails.BankDetail = new BankDetail { Name = bankDetail.Name, Code = bankDetail.Code, Id = model.BankId }; accountDetails.UpdatedAtUtc = DateTime.Now; await _accountManager.UpdateAccount(accountDetails); _log.Warn($"New account details::: {JsonConvert.SerializeObject(accountDetails)}"); return(true); } catch (Exception ex) { throw ex; } }
public ActionResult UpdateProfile(AccountDetailsModel m) { AccountDetailsModel model = m; if (m.UserType == "employee") { using (NorthwindConnection db = new NorthwindConnection()) { Employee e = db.Employees.SingleOrDefault(x => x.EmployeeID == m.Employee.EmployeeID); db.Employees.SingleOrDefault(x => x.EmployeeID == m.Employee.EmployeeID).FirstName = m.Employee.FirstName; db.Employees.SingleOrDefault(x => x.EmployeeID == m.Employee.EmployeeID).LastName = m.Employee.LastName; db.SaveChanges(); } } else { using (NorthwindConnection db = new NorthwindConnection()) { db.Customers.SingleOrDefault(x => x.CustomerID == m.Customer.CustomerID).ContactName = m.Customer.ContactName; db.Customers.SingleOrDefault(x => x.CustomerID == m.Customer.CustomerID).ContactTitle = m.Customer.ContactTitle; db.SaveChanges(); } } return(View()); }
public HttpResponseMessage UpdateProfileName(string id, [FromBody] AccountDetailsModel details) { if ((details.UserName ?? "").Length == 0 || ModelState.IsValid == false) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)); } if (User.Identity.UserId() == id) { IUser profile = repository.GetUser(id); if (profile != null) { profile.UserName = details.UserName; // Save repository.Save(profile); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, profile); response.Headers.Location = new Uri(Request.RequestUri, "/api/account/" + id); return(response); } // No such user throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)); } throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); }
public Account Balance(int accountNumber) { account = new Account(); accountDetails = new AccountDetailsModel(); account.AccountNumber = accountNumber; return(accountDetails.GetAccount(account)); }
public void Populate(RegisterOutput response) { if (response == null) { ViewModel = new NoContentResult(); return; } List <TransactionModel> transactions = new List <TransactionModel> (); foreach (var item in response.Account.Transactions) { var transaction = new TransactionModel( item.Amount, item.Description, item.TransactionDate); transactions.Add(transaction); } AccountDetailsModel account = new AccountDetailsModel(response.Account.AccountId, response.Account.CurrentBalance, transactions); List <AccountDetailsModel> accounts = new List <AccountDetailsModel> (); accounts.Add(account); CustomerModel model = new CustomerModel( response.Customer.CustomerId, response.Customer.Personnummer, response.Customer.Name, accounts ); ViewModel = new CreatedAtRouteResult("GetCustomer", new { customerId = model.CustomerId }, model); }
public async Task <IActionResult> Post([FromBody] RegisterRequest request) { var command = new RegisterCommand(request.Personnummer, request.Name, request.InitialAmount); RegisterResult result = await registerService.Process(command); List <TransactionModel> transactions = new List <TransactionModel>(); foreach (var item in result.Account.Transactions) { var transaction = new TransactionModel( item.Amount, item.Description, item.TransactionDate); transactions.Add(transaction); } AccountDetailsModel account = new AccountDetailsModel( result.Account.AccountId, result.Account.CurrentBalance, transactions); List <AccountDetailsModel> accounts = new List <AccountDetailsModel>(); accounts.Add(account); Model model = new Model( result.Customer.CustomerId, result.Customer.Personnummer, result.Customer.Name, accounts ); return(CreatedAtRoute("GetCustomer", new { customerId = model.CustomerId }, model)); }
public async Task <IActionResult> Details(string userId) { ApplicationUser user = await userService.GetById(userId); AccountDetailsModel model = user.ToAccountDetailsModel(); return(View(model)); }
private void PrintAccountDetailsToLog(AccountDetailsModel account) { _output.WriteLine($"Account details:"); _output.WriteLine($"id: \t\t{account?.Id}"); _output.WriteLine($"account: \t\t{account?.AccountName}"); _output.WriteLine($"Name: \t\t{account?.Name}"); _output.WriteLine($"include adult: \t{account?.IncludeAdult}"); _output.WriteLine($"ISO639: \t\t{account?.Iso639}"); _output.WriteLine($"ISO3166: \t{account?.Iso3166}"); }
public async Task <IActionResult> Edit(AccountDetailsModel model, List <IFormFile> UserImage) { if (ModelState.IsValid) { ActionMessage response = await userService.UpdateAsync(model, UserImage); return(RedirectToAction("ActionMessage", "Dashboard", response)); } return(View(model)); }
public IHttpActionResult GetAccountDetails(string accountNumber) { List <AccountDetailsModel> accountDetails = new List <AccountDetailsModel>(); string connectionString = ConfigurationManager.ConnectionStrings["sybaseconnection"].ToString(); string query = "select c.title_1 as acct_name, " + "b.gsm_no as Mobile_No, " + "c.class_code as class_code, " + "a.home_address as home_address " + "from zenbase..zib_ecustomer b ," + "zenbase..zib_kyc_corporate_signatories a, " + "phoenix..dp_acct c " + "where a.acct_no = b.acct_no " + "and a.acct_no = c.acct_no " + "and a.acct_no = '" + accountNumber + "'"; try { logwriter.WriteTolog("In try"); using (AseConnection connection = new AseConnection(connectionString)) { AseCommand command = new AseCommand(query, connection); connection.Open(); AseDataReader reader = command.ExecuteReader(); while (reader.Read()) { var accountDt = new AccountDetailsModel() { mobile_no = reader["Mobile_No"].ToString().Trim(), home_address = reader["home_address"].ToString().Trim(), class_code = reader["class_code"].ToString().Trim(), acct_name = reader["acct_name"].ToString().Trim() }; accountDetails.Add(accountDt); } reader.Close(); } } catch (Exception ex) { logwriter.WriteTolog("Error in inner exception: " + ex.InnerException); logwriter.WriteTolog("Error in message: " + ex.Message); } return(Ok(accountDetails)); }
// // GET: /Account/Register public ActionResult Register(string hashEmail) { var model = new AccountDetailsModel { EmailAddress = "", Password = "" }; //Get list country var listCountry = CountryList.GetCountryList("default"); ViewBag.ListCountry = listCountry; return(View(model)); }
public ActionResult Index() { AccountDetailsModel model = new AccountDetailsModel(); using (WebStoreDatabaseEntities e = new WebStoreDatabaseEntities()) { var user = e.Customers.Single(x => x.Email == User.Identity.Name); //connect db with model model.FirstName = user.FirstName; model.LastName = user.LastName; } return(View(model)); }
public async Task <IActionResult> Edit(AccountDetailsModel changes) { int rc = _accountLogic.EditAccountDetailsModel(changes, User.Identity.Name); if (rc == AccountLogic.WRONG_DATA) { ModelState.AddModelError("error_message", "Почта занята!"); } changes = _accountLogic.FormAccountDetailsModel(User.Identity.Name); return(View("~/Views/Account/AccountDetails.cshtml", changes)); }
public ActionResult Index(AccountDetailsModel model) { if (ModelState.IsValid) { using (WebStoreDatabaseEntities e = new WebStoreDatabaseEntities()) { var user = e.Customers.Single(x => x.Email == User.Identity.Name); //connects model to db user.FirstName = model.FirstName; user.LastName = model.LastName; } } return(View(model)); }
public void Should_Engage_Business_Rules_ForgotPassword() { // Arrange string testEmail = "*****@*****.**"; AccountDetailsModel detailsWithOutEmail = new AccountDetailsModel { Email = testEmail }; // Act accountController.ForgotPassword(detailsWithOutEmail); // Assert accountBusiness.Received().ForgotPassword(testEmail); }
public static void UpdateUser(AccountDetailsModel accountDetailsModel, int userId) { using (var context = DataContext.GetContext()) { var existingItem = context.Users.Single(a => a.UserId == accountDetailsModel.UserId); existingItem.Email = accountDetailsModel.Email; existingItem.FirstName = accountDetailsModel.FirstName; existingItem.LastName = accountDetailsModel.LastName; existingItem.Phone = accountDetailsModel.Phone; existingItem.LastModifiedBy = userId; existingItem.LastModifiedOn = DateTime.Now; context.SaveChanges(); } }
// happy path public async Task WhenValidArgumentsAndCalledWithRetryOption_ReturnsAccountDetails(int retryCount, int delayMilliseconds) { // Act var result = await _client.GetAccountDetails(SessionId, retryCount, delayMilliseconds); PrintResultStatusToLog(result); AccountDetailsModel account = JsonConvert.DeserializeObject <AccountDetailsModel>(result?.Json); PrintAccountDetailsToLog(account); // Assert Assert.True(result.HttpStatusCode == System.Net.HttpStatusCode.OK); Assert.True(account.AccountName == _settings.AccountName); }
// happy path public async Task WhenValidArguments_ReturnsAccountDetails() { // Act var result = await _client.GetAccountDetails(SessionId); PrintResultStatusToLog(result); AccountDetailsModel account = JsonConvert.DeserializeObject <AccountDetailsModel>(result?.Json); PrintAccountDetailsToLog(account); // Assert Assert.True(result.HttpStatusCode == System.Net.HttpStatusCode.OK); Assert.True(account.AccountName == _settings.AccountName); }
public HttpResponseMessage ChangePassword(string id, [FromBody] AccountDetailsModel details) { if ((details.Email ?? "").Length == 0 || (details.Password ?? "").Length == 0 || (details.NewPassword ?? "").Length == 0) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)); } if (User.Identity.UserId() == id) { IUser profile = repository.GetUser(id); if (profile != null) { // Ensure the email of the user logged in is being used if (profile.Email != details.Email) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); } // User must supply existing password to change his email address. Valid password and existing email try { accountBusiness.SignIn(profile.Email, details.Password); } catch (InvalidEmailOrPasswordException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); } // Retrieve the user credentials Domain.ICredentials credentials = repository.GetCredentials(profile.Email); if (credentials != null) { credentials.Password = details.NewPassword; // Save user credentials accountBusiness.ChangePassword(profile, credentials); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, profile); response.Headers.Location = new Uri(Request.RequestUri, "/api/account/" + id); return(response); } } // No such user or user has no credentials throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)); } throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); }
/// <summary> /// This action returns AccountDetails view with /// required data to be displayed passed as model /// </summary> /// <param name="accountNumber">accountNumber</param> /// <returns></returns> public ActionResult ShowAccountDetails(string accountNumber) { try { if (SessionManagement.UserInfo != null) { var organizationID = (int)SessionManagement.OrganizationID; var model = new AccountDetailsModel(); model.TransferLogDetails = new List <TransferLogDetails>(); //Get account details and latest transactions var accountDetails = clientAccBo.GetAccountDetails(accountNumber, organizationID); var latestTransactions = transferLogBO.GetLatestTransactionsForAccount(accountNumber, organizationID); //Iterate through all transactions foreach (var tran in latestTransactions) { var log = new TransferLogDetails(); log.TransactionDate = Convert.ToDateTime(tran.TransactionDateTime).ToString("dd/MM/yyyy HH:mm:ss tt"); log.TransactionType = tran.TransactionType; log.TransactionAmount = Utility.FormatCurrencyValue((decimal)tran.Amount, ""); model.TransferLogDetails.Add(log); } model.AccountNumber = accountNumber; model.Balance = Utility.FormatCurrencyValue((decimal)accountDetails.CurrentBalance, ""); model.AccountName = accountDetails.AccountName; model.IsTradingAcc = accountDetails.IsTradingAccount; model.PlatformLogin = accountDetails.PlatformLogin.ToString(); model.PlatformPassword = accountDetails.PlatformPassword; return(View("AccountDetails", model)); } else { return(RedirectToAction("Login", "Account", new { Area = "" })); } } catch (Exception ex) { CurrentDeskLog.Error(ex.Message, ex); return(View("ErrorMessage")); } }
public void Output(GetAccountDetailsOutput output) { var tables = new List <TableModel>(); foreach (var table in output.Account.Tables.GetTables()) { tables.Add(new TableModel( table.Name.ToString(), table.Id.ToGuid())); } var accountDetails = new AccountDetailsModel(output.Username, tables); var result = new GetAccountDetailsResponse(accountDetails); ViewModel = new OkObjectResult(result); }
/// <summary> /// Add or update user /// </summary> /// <param name="model">Model </param> /// <param name="userId">user id</param> /// <returns></returns> public bool AddOrUpdateUser(AccountDetailsModel model, string newUserId) { Execute("UpdateNewUserWithEnroleID", new { UserId = model.UserId, Name = model.UserName, IsEnabled = true, DateOfBirth = model.DateOfBirth, UserLevel = 1, Password = model.UserPassword ?? "", NewPassword = model.UserPassword ?? string.Empty, NewUserId = newUserId, ClientId = model.UserStoreId, EnroleID = model.EnroleId }, CommandType.StoredProcedure); return(true); }
public async Task <IActionResult> Change_password(AccountDetailsModel changes) { int rc = _accountLogic.ChangePassword(changes, User.Identity.Name); if (rc == AccountLogic.WRONG_DATA) { ModelState.AddModelError("error_message", "Старый пароль не совпадает"); } else if (rc == AccountLogic.CONFIRMED_WRONG) { ModelState.AddModelError("error_message", "Пароль повторён неверно"); } changes = _accountLogic.FormAccountDetailsModel(User.Identity.Name); return(View("~/Views/Account/AccountDetails.cshtml", changes)); }
public void Should_Validate_Email_Supplied() { // Arrange AccountDetailsModel detailsWithOutEmail = new AccountDetailsModel(); // Act try { accountController.ForgotPassword(detailsWithOutEmail); } catch (HttpResponseException exception) { Assert.IsTrue(exception.Response.StatusCode == HttpStatusCode.BadRequest, "Email not supplied. Expected Bad Request"); return; } Assert.Fail("Expected Bad Request"); }
public HttpResponseMessage UpdateProfileEmail(string id, [FromBody] AccountDetailsModel details) { if ((details.Email ?? "").Length == 0 || ModelState.IsValid == false) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)); } if (User.Identity.UserId() == id) { IUser profile = repository.GetUser(id); if (profile != null) { // User must supply a password to change his email address. Valid password and existing email try { accountBusiness.SignIn(profile.Email, details.Password); } catch (InvalidEmailOrPasswordException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); } Domain.ICredentials credentials = repository.GetCredentials(profile.Email); if (credentials != null) { profile.Email = details.Email; credentials.Email = details.Email; // Save repository.Save(profile); repository.Save(credentials); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, profile); response.Headers.Location = new Uri(Request.RequestUri, "/api/account/" + id); return(response); } } // No such user throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)); } throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); }