public ActionResult AddTeller(TellerViewModel tellerViewModel) { tellerViewModel.Teller.TillAccountBalance = 0; var tillAccountId = tellerViewModel.Teller.TillAccountId; var users = _context.Users.ToList(); // var accounts = _context.GlAccounts.Include(c=>c.GlCategories).Where(c=>c.GlCategories.Name.Equals("Cash")).ToList(); var accounts = _context.GlAccounts.Include(c => c.GlCategories).Where(c => c.GlCategories.Name.Equals("Cash")).ToList(); var glTill = _context.GlAccounts.SingleOrDefault(c => c.Id == tillAccountId); var glCategories = _context.GlCategories.ToList(); var categories = _context.Categories.ToList(); List <GLAccount> tillAccounts = new List <GLAccount>(); foreach (var account in accounts) { // if (account.GlCategoriesId == glCategory.Id && account.IsAssigned==false) if (account.IsAssigned == false) { if (!account.Name.Equals(CBA.COT_INCOME_RECEIVABLE_GL_ACC_NAME) || !account.Name.Equals(CBA.PRINCIPAL_OVERDUE_ACC_NAME) || !account.Name.Equals(CBA.INTEREST_RECEIVABLE_ACC_NAME) || !account.Name.Equals(CBA.CUSTOMER_LOAN_ACCOUNT)) { tillAccounts.Add(account); } } } if (CheckIfUserHasBeenAssignedTeller(tellerViewModel.Teller.UserTellerId)) { var viewModel = new TellerViewModel() { Users = users, Teller = new Teller(), TillAccounts = tillAccounts }; return(View("Index", viewModel)); } tellerViewModel.Teller.IsAssigned = true; if (!ModelState.IsValid) { var viewModel = new TellerViewModel() { Users = users, Teller = new Teller(), TillAccounts = tillAccounts }; return(View("Index", viewModel)); } var teller = new Teller { IsAssigned = tellerViewModel.Teller.IsAssigned, TillAccountId = tellerViewModel.Teller.TillAccountId, UserTellerId = tellerViewModel.Teller.UserTellerId, TillAccountBalance = glTill.AccountBalance }; _context.Tellers.Add(teller); _context.SaveChanges(); MarkAsAssigned(tillAccountId); tellerViewModel.Users = users; tellerViewModel.TillAccounts = tillAccounts; tellerViewModel.Teller = new Teller(); return(RedirectToAction("Index", "Tellers")); }
// GET: Tellers public ActionResult Index() { var users = _context.Users.ToList(); // var accounts = _context.GlAccounts.Include(c=>c.GlCategories).ToList(); var accounts = _context.GlAccounts.Include(c => c.GlCategories).Where(c => c.GlCategories.Name.Equals("Cash")).ToList(); var glCategories = _context.GlCategories.ToList(); var categories = _context.Categories.ToList(); var count = _context.Tellers.Count(); List <GLAccount> tillAccounts = new List <GLAccount>(); foreach (var account in accounts) { // if (account.GlCategoriesId == glCategory.Id && account.IsAssigned==false) if (account.IsAssigned == false) { if (!account.Name.Equals(CBA.COT_INCOME_RECEIVABLE_GL_ACC_NAME) || !account.Name.Equals(CBA.PRINCIPAL_OVERDUE_ACC_NAME) || !account.Name.Equals(CBA.INTEREST_RECEIVABLE_ACC_NAME) || !account.Name.Equals(CBA.CUSTOMER_LOAN_ACCOUNT)) { tillAccounts.Add(account); } } } // foreach (var category in categories) // { // if (category.Name.Equals("Asset")) // { // foreach (var glCategory in glCategories) // { // if (glCategory.Name.Equals("Cash") && glCategory.CategoriesId == category.Id) // // foreach (var account in accounts) // { // // if (account.GlCategoriesId == glCategory.Id && account.IsAssigned==false) // if (account.GlCategoriesId == glCategory.Id && account.IsAssigned == false) // { // if (!account.Name.Equals(CBA.COT_INCOME_RECEIVABLE_GL_ACC_NAME) || // !account.Name.Equals(CBA.PRINCIPAL_OVERDUE_ACC_NAME) || // !account.Name.Equals(CBA.INTEREST_RECEIVABLE_ACC_NAME) || // !account.Name.Equals(CBA.CUSTOMER_LOAN_ACCOUNT)) // { // tillAccounts.Add(account); // } // } // // } // // } // } // // } var viewModel = new TellerViewModel() { Users = users, Teller = new Teller(), TillAccounts = tillAccounts, count = count }; return(View("Index", viewModel)); }
public TellerWindow(Employee employee) { InitializeComponent(); DataContext = new TellerViewModel(employee); }