public IActionResult Save(EmployeeBanking employeeBanking) { var employeeBankingInformation = _employeeBankingRepository.GetEmployeeBankingInformationById(employeeBanking.EmployeeBankingID); if (employeeBankingInformation == null) { _employeeBankingRepository.AddEmployeeBankingInformation(employeeBanking); } else { _employeeBankingRepository.UpdateEmployeeBankingInformation(employeeBanking); } return(RedirectToAction("List", "Employee")); }
public EmployeeBanking UpdateEmployeeBankingInformation(EmployeeBanking employeeBanking) { var employeeBankingInformation = _context.EmployeeBankings.FirstOrDefault(e => e.EmployeeID == employeeBanking.EmployeeID); employeeBanking.AccountNumber = employeeBanking.AccountNumber; employeeBanking.City = employeeBanking.City; employeeBanking.InstituteNumber = employeeBanking.InstituteNumber; employeeBanking.NameOfBank = employeeBanking.NameOfBank; employeeBanking.PostalCode = employeeBanking.PostalCode; employeeBanking.Province = employeeBanking.Province; employeeBanking.TransitNumber = employeeBanking.TransitNumber; _context.Update(employeeBanking); _context.SaveChanges(); return(employeeBanking); }
public EmployeeBanking AddEmployeeBankingInformation(EmployeeBanking employeeBanking) { EmployeeBanking newEmployeeBanking = new EmployeeBanking { AccountNumber = employeeBanking.AccountNumber, City = employeeBanking.City, InstituteNumber = employeeBanking.InstituteNumber, NameOfBank = employeeBanking.NameOfBank, PostalCode = employeeBanking.PostalCode, Province = employeeBanking.Province, TransitNumber = employeeBanking.TransitNumber, EmployeeID = employeeBanking.EmployeeID }; _context.Add(newEmployeeBanking); _context.SaveChanges(); return(newEmployeeBanking); }