public IHttpActionResult PutFinancialInstitution(Guid id, FinancialInstitution financialInstitution) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != financialInstitution.FinancialInstitutionID) { return(BadRequest()); } db.Entry(financialInstitution).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!FinancialInstitutionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostFinancialInstitution(FinancialInstitution financialInstitution) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.FinancialInstitutions.Add(financialInstitution); try { db.SaveChanges(); } catch (DbUpdateException) { if (FinancialInstitutionExists(financialInstitution.FinancialInstitutionID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = financialInstitution.FinancialInstitutionID }, financialInstitution)); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (FinancialInstitution != null) { hashCode = hashCode * 59 + FinancialInstitution.GetHashCode(); } if (Abn != null) { hashCode = hashCode * 59 + Abn.GetHashCode(); } if (Acn != null) { hashCode = hashCode * 59 + Acn.GetHashCode(); } if (Arbn != null) { hashCode = hashCode * 59 + Arbn.GetHashCode(); } return(hashCode); } }
private void SetNewInstitution(FinancialInstitution institution) { CurrentPixKey.FinancialInstitution = institution; CurrentPixKey.Color = institution.Style; CurrenSelectedFinancialInstitutionText = institution.Name; App.LoadTheme(CurrentPixKey.Color); ReloadStatusBar(); }
/// <summary> /// Add an account to the database - Using OFX data specification /// </summary> /// <param name="account">Populated account object to add to database</param> /// <param name="financialInstitution">OFX financial institution to link in database. Will be created if necessary.</param> /// <param name="fiUser">User credentials for the financial institution</param> /// <returns>Created account</returns> public Account AddAccount(Account account, OFX.Types.FinancialInstitution financialInstitution, FinancialInstitutionUser fiUser) { // TODO: See if there's an existing FI or user with this info already // Look for existing FI entry with the same name FinancialInstitution fi; try { fi = DbContext.FinancialInstitutions.First(i => i.Name == financialInstitution.Name); } catch (Exception ex) { // Can result in InvalidOperationException or NullReferenceException depending on provider if (ex is InvalidOperationException || ex is NullReferenceException) { // FI Doesn't exist, add a new one fi = new FinancialInstitution { Name = financialInstitution.Name, OfxFinancialUnitId = financialInstitution.FinancialId, OfxOrganizationId = financialInstitution.OrganizationId, OfxUpdateUrl = financialInstitution.ServiceEndpoint.ToString() }; DbContext.FinancialInstitutions.Add(fi); } else { throw; // Unhandled } } // Look for existing user under this FI with same userId try { fiUser = fi.Users.First(u => u.UserId == fiUser.UserId && u.Password == fiUser.Password); } catch (Exception ex) { // Can result in InvalidOperationException or NullReferenceException depending on provider if (ex is InvalidOperationException || ex is NullReferenceException) { // User doesn't exist, add as new fi.Users.Add(fiUser); DbContext.FinancialInstitutionUsers.Add(fiUser); } else { throw; // Unhandled } } fiUser.Accounts.Add(account); DbContext.Accounts.Add(account); return(account); }
public IHttpActionResult GetFinancialInstitution(Guid id) { FinancialInstitution financialInstitution = db.FinancialInstitutions.Find(id); if (financialInstitution == null) { return(NotFound()); } return(Ok(financialInstitution)); }
public IHttpActionResult DeleteFinancialInstitution(Guid id) { FinancialInstitution financialInstitution = db.FinancialInstitutions.Find(id); if (financialInstitution == null) { return(NotFound()); } db.FinancialInstitutions.Remove(financialInstitution); db.SaveChanges(); return(Ok(financialInstitution)); }
/// <summary> /// Verify the provided account credentials. Raises an exception if validation fails /// </summary> /// <param name="financialInstitution">Financial institution to query</param> /// <param name="fiCredentials">Credentials for financial institution account</param> /// <returns>List of accounts</returns> public static async Task VerifyAccountCredentials(FinancialInstitution financialInstitution, OFX.Types.Credentials fiCredentials) { using (BackgroundTaskTracker.BeginTask("Verifying Credentials")) { // Convert from data model FI into OFX FI var ofxFinancialInstitition = new OFX.Types.FinancialInstitution(financialInstitution.Name, new Uri(financialInstitution.OfxUpdateUrl), financialInstitution.OfxOrganizationId, financialInstitution.OfxFinancialUnitId); var ofxService = new OFX2Service(ofxFinancialInstitition, fiCredentials); // Call list accounts to validate credentials await ofxService.ListAccounts().ConfigureAwait(false); } }
public JsonResult GetFinancialInsByLoginId(string loginId) { var entity = new FinancialInstitution(); var entityDTO = new FinancialInstitutionDTO(); try { entity = _businessLayer.GetAllFinInstitutionInfos().Where(x => x.LoginId == loginId).FirstOrDefault(); if (entity != null) { entityDTO.Id = entity.Id; entityDTO.InstitutionName = entity.InstitutionName; } } catch (WebException) { } return(Json(entityDTO)); }
public DataDefinitions() { InitializeComponent(); Holder holder = new Holder(); HoldersItems = holder.HolderCollection(); HoldersRadio.DataContext = this; FinancialInstitution financialinstitutions = new FinancialInstitution(); FinancialInstitutions = financialinstitutions.GetFinancialInstitutions(); Accounts = FinancialInstitutions.First().Accounts; if (!Accounts.Any(r => r.IsChecked == true)) { Accounts.First().IsChecked = true; } ReportFormats = Accounts.First().ExcelImportFormats; if (!ReportFormats.Any(r => r.IsChecked == true)) { ReportFormats.First().IsChecked = true; } comboBank.DataContext = this; comboBank.SelectedIndex = 0; AccountRadio.DataContext = this; comboFormat.DataContext = this; comboFormat.SelectedIndex = 0; comboDate.SelectedIndex = 4; Holders.ItemsSource = holder.GetHolders; Categories.ItemsSource = BudgetCategory.GetCategories(); CustomCategories.ItemsSource = BudgetCategory.GetCategories().Concat(new[] { "" }); SetSalaryDatepicker(); DisplayDefaultSalary(); DataGridDefinitions.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged; UpdateDataGrid(); }
/// <summary> /// Returns true if BankingAuthorisedEntity instances are equal /// </summary> /// <param name="other">Instance of BankingAuthorisedEntity to be compared</param> /// <returns>Boolean</returns> public bool Equals(BankingAuthorisedEntity other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( FinancialInstitution == other.FinancialInstitution || FinancialInstitution != null && FinancialInstitution.Equals(other.FinancialInstitution) ) && ( Abn == other.Abn || Abn != null && Abn.Equals(other.Abn) ) && ( Acn == other.Acn || Acn != null && Acn.Equals(other.Acn) ) && ( Arbn == other.Arbn || Arbn != null && Arbn.Equals(other.Arbn) )); }
public ConcreteFinancialInstitutionCommand(FinancialInstitution financialInstitution, decimal amount) { this._financialInstitution = financialInstitution; this._amount = amount; }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { BusinessLayer businessLayer = new BusinessLayer(); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { //returnUrl = returnUrl ?? Url.Content("~/"); returnUrl = returnUrl ?? Url.Content("~/Users/Index?userType=" + Input.UserType); IDTPCryptography cryptography = new IDTPCryptography(); //Getting password salt to encrypt string passSalt = cryptography.GetSecretSalt(); var user = new ApplicationUser(); switch (Input.UserType) { case "Admin": { user = new ApplicationUser { UserName = Input.UserId, Email = Input.Email, SecretSalt = passSalt }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { IDTPUserAdmin newUser = new IDTPUserAdmin { Id = user.Id, FirstName = Input.FirstName, LastName = Input.LastName, ContactNo = Input.ContactNo, Email = Input.Email, LoginId = Input.UserId, NID = Input.NID, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, EntityState = EntityState.Added }; businessLayer.AddUser(newUser); await _userManager.AddToRoleAsync(user, "IDTPAdmin"); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } if (!ModelState.IsValid) { TempData["form"] = Input.UserType; return(Page()); } else { //await _signInManager.SignInAsync(user, isPersistent: false); return(LocalRedirect(returnUrl)); } } case "Business": { user = new ApplicationUser { UserName = Input.BusinessId, Email = Input.BusinessEmail, SecretSalt = passSalt }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { Business newUser = new Business { Id = user.Id, FullName = Input.BusinessName, ContactNo = Input.BusinessContactNo, Email = Input.BusinessEmail, LoginId = Input.BusinessId, NID = Input.BusinessNID, TIN = Input.BusinessTIN, BIN = Input.BusinessBIN, BankName = Input.BusinessBankName, BranchName = Input.BusinessBranchName, AccountNumber = Input.BusinessAccountNumber, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, EntityState = EntityState.Added }; businessLayer.AddMerchant(newUser); await _userManager.AddToRoleAsync(user, "Business"); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } if (!ModelState.IsValid) { TempData["form"] = Input.UserType; return(Page()); } else { //await _signInManager.SignInAsync(user, isPersistent: false); return(LocalRedirect(returnUrl)); } } case "GovtInstitute": { user = new ApplicationUser { UserName = Input.GovtId, Email = Input.GovtEmail, SecretSalt = passSalt }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { GovernmentInstitution newGovtInstitutionInfo = new GovernmentInstitution { LoginId = Input.GovtId, Name = Input.GovtInstitutionName, BIN = Input.GovtBIN, Email = Input.GovtEmail, ContactNo = Input.GovtContactNo, Address = Input.Address, BankName = Input.GovtBankName, BranchName = Input.GovtBranchName, AccountNumber = Input.GovtAccountNumber, ContactPersonName = Input.ContactPersonName, ContactPersonDesignation = Input.ContactPersonDesignation, ContactPersonEmail = Input.ContactPersonEmail, ContactPersonMobile = Input.ContactPersonMobile, ContactPersonNID = Input.ContactPersonNID, ContactPersonOffice = Input.ContactPersonOffice, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, EntityState = EntityState.Added }; businessLayer.AddGovtInstitutionInfo(newGovtInstitutionInfo); await _userManager.AddToRoleAsync(user, "GovernmentInstitute"); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } if (!ModelState.IsValid) { TempData["form"] = Input.UserType; return(Page()); } else { //await _signInManager.SignInAsync(user, isPersistent: false); return(LocalRedirect(returnUrl)); } } case "FinInstitute": { user = new ApplicationUser { UserName = Input.FinancialId, Email = Input.FinancialEmail, SecretSalt = passSalt }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { FinancialInstitution newFinInstitutionInfo = new FinancialInstitution { Id = user.Id, LoginId = Input.FinancialId, InstitutionName = Input.FinancialInstitutionName, TIN = Input.FinancialTIN, BIN = Input.FinancialBIN, Email = Input.FinancialEmail, ContactNo = Input.FinancialContactNo, SwiftCode = Input.FinancialSwiftCode, VatId = Input.FinancialVatId, ContactPersonName = Input.ContactPersonName, ContactPersonDesignation = Input.ContactPersonDesignation, ContactPersonEmail = Input.ContactPersonEmail, ContactPersonMobile = Input.ContactPersonMobile, ContactPersonNID = Input.ContactPersonNID, ContactPersonOffice = Input.ContactPersonOffice, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, EntityState = EntityState.Added }; businessLayer.AddFinInstitutionInfo(newFinInstitutionInfo); await _userManager.AddToRoleAsync(user, "FinancialInstitute"); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } if (!ModelState.IsValid) { TempData["form"] = Input.UserType; return(Page()); } else { //await _signInManager.SignInAsync(user, isPersistent: false); return(LocalRedirect(returnUrl)); } } } } // If we got this far, something failed, redisplay form TempData["form"] = Input.UserType; return(Page()); }
public MyShim(FinancialInstitution inner) {this.inner = inner;}
public void GetStatementItems(bool first) { //filling textblocks MonthlyStatement statement = new MonthlyStatement(); Dispatcher.Invoke(() => { statement.statement_date = (DateTime)date_month.SelectedDate; statement.holder = HoldersItems.Where(r => r.IsChecked == true).Select(x => x.HolderName).First(); Dictionary <string, double> category_amounts = statement.GetAggregateCategoryAmount(); ///grid assets NetWorthGrid.Children.Clear(); List <AccountType> acctypes = new List <AccountType>(); FinancialInstitution financialinstitutions = new FinancialInstitution(); int row = 1; foreach (FinancialInstitution fi in financialinstitutions.GetFinancialInstitutions().Where(e => e.Accounts.Any(a => a.AccountType != AccountType.CreditCard))) { if (first) { NetWorthGrid.RowDefinitions.Add(new RowDefinition()); } TextBlock txt_fi = Helpers.GridHelper.CreateTextInGrid(fi.InstitutionName, row, 0, false, HorizontalAlignment.Left, false, true, true); NetWorthGrid.Children.Add(txt_fi); foreach (Account acc in fi.Accounts) { if (acc.AccountType != AccountType.CreditCard) { if (!acctypes.Contains(acc.AccountType)) { if (first) { NetWorthGrid.ColumnDefinitions.Add(new ColumnDefinition()); } TextBlock txt_acc = Helpers.GridHelper.CreateTextInGrid(acc.AccountTypeDescription, 0, acctypes.Count + 1, false, HorizontalAlignment.Center, true, false, true); NetWorthGrid.Children.Add(txt_acc); acctypes.Add(acc.AccountType); } double balance = statement.GetBalance(acc.AccountType, fi.ShortName); TextBlock txt_data = Helpers.GridHelper.CreateTextInGrid(string.Format("{0:C2}", balance), row, acctypes.IndexOf(acc.AccountType) + 1, false, HorizontalAlignment.Right, false, false, true); NetWorthGrid.Children.Add(txt_data); } } row++; } if (first) { NetWorthGrid.ColumnDefinitions.Add(new ColumnDefinition()); } TextBlock txt_total_bank = Helpers.GridHelper.CreateTextInGrid("Total", 0, acctypes.Count + 1, false, HorizontalAlignment.Center, true, false, true); NetWorthGrid.Children.Add(txt_total_bank); for (int r = 1; r < row; r++) { double amount = 0; for (int c = 1; c <= acctypes.Count; c++) { TextBlock selected_txt = NetWorthGrid.Children.Cast <TextBlock>().Where(e => Grid.GetColumn(e) == c && Grid.GetRow(e) == r).FirstOrDefault(); if (selected_txt != null) { amount += Convert.ToDouble(selected_txt.Text.Replace("$", "").Replace(",", "")); } } txt_total_bank = Helpers.GridHelper.CreateTextInGrid(string.Format("{0:C2}", amount), r, acctypes.Count + 1, false, HorizontalAlignment.Right, true, false, true); NetWorthGrid.Children.Add(txt_total_bank); } if (first) { NetWorthGrid.RowDefinitions.Add(new RowDefinition()); } TextBlock txt_total_accounttype = Helpers.GridHelper.CreateTextInGrid("Total", row, 0, false, HorizontalAlignment.Left, true, false, true); NetWorthGrid.Children.Add(txt_total_accounttype); for (int c = 1; c <= acctypes.Count + 1; c++) { double amount = 0; for (int r = 1; r < row; r++) { TextBlock selected_txt = NetWorthGrid.Children.Cast <TextBlock>().Where(e => Grid.GetColumn(e) == c && Grid.GetRow(e) == r).FirstOrDefault(); if (selected_txt != null) { amount += Convert.ToDouble(selected_txt.Text.Replace("$", "").Replace(",", "")); } } txt_total_accounttype = Helpers.GridHelper.CreateTextInGrid(string.Format("{0:C2}", amount), row, c, false, HorizontalAlignment.Right, true, false, true); NetWorthGrid.Children.Add(txt_total_accounttype); } ///grid statement amt_gross_salary.Text = string.Format("{0:C2}", category_amounts["Gross Salary"]); //amt_ret_contribution.Text = string.Format("{0:C2}", -1 * category_amounts["Retirement Contribution"]); amt_netpay.Text = string.Format("{0:C2}", category_amounts["Payroll"]); amt_other_withholding.Text = (-1 * (double.Parse(amt_gross_salary.Text, NumberStyles.Currency) - double.Parse(amt_netpay.Text, NumberStyles.Currency) + double.Parse(amt_ret_contribution.Text, NumberStyles.Currency))).ToString("C2"); //amt_ret_income.Text = string.Format("{0:C2}", category_amounts["Retirement Income"]); amt_other_income.Text = string.Format("{0:C2}", category_amounts["Other Income"]); amt_total_income.Text = (double.Parse(amt_netpay.Text, NumberStyles.Currency) + double.Parse(amt_ret_income.Text, NumberStyles.Currency) + double.Parse(amt_other_income.Text, NumberStyles.Currency)).ToString("C2"); amt_rent.Text = string.Format("{0:C2}", category_amounts["Rent"]); amt_utilities.Text = string.Format("{0:C2}", category_amounts["Utilities"]); amt_commute.Text = string.Format("{0:C2}", category_amounts["Commute"]); amt_groceries.Text = string.Format("{0:C2}", category_amounts["Groceries"]); amt_restaurants.Text = string.Format("{0:C2}", category_amounts["Restaurants"]); amt_cash.Text = string.Format("{0:C2}", category_amounts["Cash"]); amt_living_expense.Text = (double.Parse(amt_rent.Text, NumberStyles.Currency) + double.Parse(amt_utilities.Text, NumberStyles.Currency) + double.Parse(amt_commute.Text, NumberStyles.Currency) + double.Parse(amt_groceries.Text, NumberStyles.Currency) + double.Parse(amt_restaurants.Text, NumberStyles.Currency) + double.Parse(amt_cash.Text, NumberStyles.Currency)).ToString("C2"); amt_shopping.Text = string.Format("{0:C2}", category_amounts["Shopping"]); amt_entertainment.Text = string.Format("{0:C2}", category_amounts["Entertainment"]); amt_travel.Text = string.Format("{0:C2}", category_amounts["Travel"]); amt_medical.Text = string.Format("{0:C2}", category_amounts["Medical"]); amt_other_expense.Text = (double.Parse(amt_shopping.Text, NumberStyles.Currency) + double.Parse(amt_entertainment.Text, NumberStyles.Currency) + double.Parse(amt_travel.Text, NumberStyles.Currency) + double.Parse(amt_medical.Text, NumberStyles.Currency)).ToString("C2"); amt_total_expense.Text = (double.Parse(amt_living_expense.Text, NumberStyles.Currency) + double.Parse(amt_other_expense.Text, NumberStyles.Currency)).ToString("C2"); amt_savings_before_misc.Text = (double.Parse(amt_total_income.Text, NumberStyles.Currency) + double.Parse(amt_total_expense.Text, NumberStyles.Currency)).ToString("C2"); amt_misc.Text = string.Format("{0:C2}", category_amounts["Miscellaneous"]); amt_investment_gains.Text = string.Format("{0:C2}", category_amounts["Investment Gains"]); amt_net_savings.Text = (double.Parse(amt_total_income.Text, NumberStyles.Currency) + double.Parse(amt_total_expense.Text, NumberStyles.Currency) + double.Parse(amt_misc.Text, NumberStyles.Currency) + double.Parse(amt_investment_gains.Text, NumberStyles.Currency) ).ToString("C2"); }); }