public void GetBenefitDeductionsPositive() { IEmployeeRepository EmployeeRepos = new EmployeeRepository(); var AEmployee = EmployeeRepos.GetEmployeeById(1); Assert.IsNotNull(AEmployee); List <IFamilyMember> FamilyMembers = EmployeeRepos.GetFamilyMembers(AEmployee); Assert.IsNotNull(FamilyMembers); ISalaryRepository SalaryEmployeeRepos = new SalaryRepository(AEmployee); ISalary AEmployeeSalary = SalaryEmployeeRepos.GetSalary(); Assert.IsNotNull(AEmployeeSalary); IBenefitDeductionRepository BenefitDeductionRepos = new BenefitDeductionRepository(AEmployee, FamilyMembers, AEmployeeSalary); IBenefitDeductionDetail ABenefitDeductionDetail = BenefitDeductionRepos.CalculateBenefitDeductionDetail(); Assert.IsNotNull(ABenefitDeductionDetail); }
public Programmer(int id, double salary) { s = this; s.Id = id; s.Salary = salary; s.Dictionary.Add(s.Id, s.Salary); }
public SalaryController(ISalary salary, IUserProfile userProfile, StaffPortalDataContext context, UserManager <ApplicationUser> userManager) { _salary = salary; _context = context; _userProfile = userProfile; _userManager = userManager; }
/// <summary> /// Пересчет ЗП при обновлении ячеек. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataGrid_OnCurrentCellChanged(object sender, EventArgs e) { ISalary salary = null; if (dataGrid.SelectedItem is Analyst) { salary = dataGrid.SelectedItem as Analyst; } else if (dataGrid.SelectedItem is Director) { salary = dataGrid.SelectedItem as Director; } else if (dataGrid.SelectedItem is Intern) { salary = dataGrid.SelectedItem as Intern; } else if (dataGrid.SelectedItem is Manager) { salary = dataGrid.SelectedItem as Manager; } else if (dataGrid.SelectedItem is QaEngineer) { salary = dataGrid.SelectedItem as QaEngineer; } salary?.CalcSalary(); Company.UpdateDirectorSalaryCoefficient(Company.Departments); salary = dataGrid.SelectedItem as Director; salary?.CalcSalary(); }
static void Main(string[] args) { IWorker[] workers = new IWorker[3] { new Manager(), new Worker(), new Robot(), }; foreach (var worker in workers) { worker.Work(); } IEat[] eats = new IEat[2] { new Manager(), new Worker(), }; foreach (var eat in eats) { eat.Eat(); } ISalary[] salaries = new ISalary[2] { new Manager(), new Worker(), }; foreach (var salary in salaries) { salary.GetSalary(); } }
public SalaryCalculator() { this.log += new Log(WriteLog); Trace.Listeners.Clear(); Trace.Listeners.Add(consoleListener); Trace.Listeners.Add(fileListener); Debug.Listeners.Add(new TextWriterTraceListener("log_file.txt")); Object tmp; try { Assembly assembly = Assembly.LoadFile(Path.GetFullPath("Salary Plugin.dll")); Type type = assembly.GetType("SalaryPlugin.SalaryPlugin"); if (type != null) { tmp = Activator.CreateInstance(type); if (tmp is ISalary) { plugin = (ISalary)tmp; } } } catch (FileException er) { WriteLog("Nelze načíst dll soubor " + er.Message); throw new FileException("Nelze načíst dll soubor " + er.Message); } log("Plugin se načetl"); }
static void Main(string[] args) { IWorker[] workers = new IWorker[3] { new Worker(), new Manager(), new Robot() }; foreach (var worker in workers) { worker.Work(); } IEat[] eats = new IEat[2] { new Manager(), new Worker() }; ISalary[] salaries = new ISalary[2] { new Manager(), new Worker() }; }
public async Task <EmployeeResponseModel> GetEmployeeAsync(int id) { EmployeeResponseModel employeeModel = new EmployeeResponseModel(); IEnumerable <Employee> employees = await employeeService.GetEmployees(); Employee employee = employees.SingleOrDefault(s => s.Id == id); if (employee != null) { ISalary salary = salaryFactory.SelectEmployeeType(employee.ContractTypeName); employeeModel = new EmployeeResponseModel { Id = employee.Id, RoleId = employee.RoleId, RoleName = employee.RoleName, Name = employee.Name, RoleDescription = employee.RoleDescription, ContractTypeName = employee.ContractTypeName, Salary = salary.GetSalary(employee), AnualSalary = salary.GetAnualSalary(employee) }; } return(employeeModel); }
static void Main(string[] args) { ProjectManager projectManager = new ProjectManager(); IWorker[] workers = new IWorker[3] { new Manager(), new Worker(), new Robot() }; IEat[] eats = new IEat[2] { new Manager(), new Worker() }; ISalary[] getSalaries = new ISalary[2] { new Manager(), new Worker() }; projectManager.Work(workers); projectManager.Eat(eats); projectManager.GetSalary(getSalaries); }
static void Main(string[] args) { // Bir class birden fazla interface implement edebilir. // Interface Segregation, SOLID - I // Arayüz ayrımı IWork[] workers = new IWork[] { new Manager(), new Worker(), new Robot() }; foreach (var worker in workers) { worker.Work(); // Tüm çalışanlara çalışma emri gönderildi. } IEat[] eats = new IEat[] { new Manager(), new Worker() }; foreach (var eat in eats) { eat.Eat(); // Tüm çalışanlara yemek vakti anonsu gönderildi. } ISalary[] getPaid = new ISalary[] { new Manager(), new Worker() }; foreach (var pay in getPaid) { pay.GetSalary(); // Tüm çalışanlara ödeme gönderildi. } }
public ManagerProxy(int goals, int cards) { _goals = goals; _cards = cards; _footballerSalary = new FootballerSalary(goals > 0, cards > 0); }
public void ExecuteStrategyAndReturnSalaryObject([Values(1000, 5000)] decimal grossSalary) { _coreSalaryStrategy.GrossSalary = grossSalary; ISalary salary = new bc.Salary(); salary.GrossSalary = grossSalary; salary.TaxableIncome = grossSalary; decimal deductionsAmount = (decimal)600; var deductionsList = new List <Tuple <string, decimal> >() { Tuple.Create <string, decimal>("a", (decimal)100), Tuple.Create <string, decimal>("b", (decimal)200), Tuple.Create <string, decimal>("c", (decimal)300) }; _deductionsMock.Setup(d => d.GetDeductionsReport()).Returns(deductionsList); _deductionsMock.Setup(d => d.GetTotalDeductionsAmount(It.IsAny <decimal>())).Returns(deductionsAmount); salary.Deductions = deductionsList; salary.NetAnnualSalary = (salary.TaxableIncome - deductionsAmount); ISalary calculatedSalary = _coreSalaryStrategy.Execute(); Assert.AreEqual(salary.GrossSalary, calculatedSalary.GrossSalary); Assert.AreEqual(salary.TaxableIncome, calculatedSalary.TaxableIncome); Assert.AreEqual(salary.NetAnnualSalary, calculatedSalary.NetAnnualSalary); Assert.AreEqual(salary.Deductions, calculatedSalary.Deductions); }
public Person(IList <ILoan> loans, decimal extraLoanRepayment, ISalary salary) { Loans = loans; InitialExtraLoanPayment = extraLoanRepayment; ExtraLoanPaymentFromRaises = 0; Salary = salary; }
static void Main(string[] args) { //Interface'leri dogru kullanarak böllerek SOLID in Interface Segregation Principles 'ı uyguladık bu uygulamamızda. IWorker[] workers = new IWorker[3] { new Employee(), new Manager(), new Robot() }; IEat[] eats = new IEat[2] { new Employee(), new Manager() }; ISalary[] salaries = new ISalary[2] { new Employee(), new Manager() }; foreach (var worker in workers) { worker.Work(); } foreach (var eat in eats) { eat.Eat(); } foreach (var salary in salaries) { salary.GetSalary(); } Console.ReadLine(); }
static void Main(string[] args) { //Multiple implementations: IWorker[] workers = new IWorker[3] { new Manager(), new Worker(), new Robot() }; foreach (var worker in workers) { worker.work(); } IEat[] eats = new IEat[2] { new Manager(), new Worker() }; foreach (var eat in eats) { eat.eat(); } ISalary[] salaries = new ISalary[2] { new Manager(), new Worker() }; foreach (var salary in salaries) { salary.GetSalary(); } }
static void Main(string[] args) { //Interfacelerin kullanım şekilleri CustomerManager customerManger = new CustomerManager(); //customerManger.Add(new SQLiteDal()); //customerManger.Delete(new OracleDal()); ICustomerDal[] customerDals = new ICustomerDal[] { new SQLiteDal(), new OracleDal() }; foreach (ICustomerDal customerDal in customerDals) { customerDal.Add(); customerDal.Delete(); customerDal.Update(); } //Çoklu implementasyon örneği için MultiImplementation.cs bakınız... //Devamı IWork[] workersArray = new IWork[] { new Manager(), new Worker(), new Robot() }; IEat[] eatArray = new IEat[] { new Manager(), new Worker() }; ISalary[] salaryArray = new ISalary[] { new Manager(), new Worker() }; foreach (IWork worker in workersArray) { worker.Work(); } foreach (IEat eater in eatArray) { eater.Eat(); } foreach (ISalary salaryGetter in salaryArray) { salaryGetter.Salary(); } Console.Read(); }
static void Main(string[] args) { ISalary salary = null; Employee emplopee = new Employee(); string country = string.Empty; while (true) { string type = Console.ReadLine(); switch (type) { case "c": salary = new ChineseSalary(); country = "Chinese"; break; case "a": salary = new AmericanSalary(); country = "American"; break; default: Console.WriteLine("Please key in 'a' or 'c'!"); country = string.Empty; break; } if (!string.IsNullOrEmpty(country)) { emplopee.SetEmployee(salary); Console.WriteLine(country + "'s salary: " + emplopee.GetSalary()); country = string.Empty; } } }
public virtual ISalary CalculateNetSalary() { ISalary calculatedSalary = _salaryStrategy.Execute(); EmployeeSalary = calculatedSalary; _log.DebugFormat("Calculated net salary for {0}: {1}", Name, calculatedSalary.NetAnnualSalary); return(calculatedSalary); }
public SalaryController(EmployeeDataContext context, ISalary sal, IGrade grade, IUser user, UserManager <Account> userManager) { _sal = sal; _grade = grade; _userManager = userManager; _user = user; _context = context; }
private void buttonОК_Click(object sender, EventArgs e) { if (modifyPersonControl.ExitCondition) { modifyPerson = modifyPersonControl.Person; Close(); } }
public bool Equals(ISalary other) { if (other is NoSalary) { return(true); } return(false); }
protected override void DoServiceExecute(EmployeeCalculateSalaryServiceRequest request) { _log.DebugFormat("Request to calculate net salary for employee: {0}", request.EmployeeName); var employee = _employeeDao.Get(request.EmployeeName); _calculatedSalary = employee.CalculateNetSalary(); _log.DebugFormat("Employee {0}, Gross salary={1}, Net salary={2}", employee.Name, _calculatedSalary.GrossSalary, _calculatedSalary.NetAnnualSalary); _employeeDao.Save(employee); }
static void Main(string[] args) { var person = new Person(); ISalary salary = person; //boxing, temp copy, vtable lookup Console.WriteLine(person); salary.Increase(); Console.WriteLine(person); }
public bool Equals(ISalary other) { if (other is PlayersSalaryRegular regular) { return(SalaryInterval == regular.SalaryInterval && SalaryAmount == regular.SalaryAmount && CurrencyCode == regular.CurrencyCode); } return(false); }
public void ExecuteStrategyAndReturnSalaryObject() { _australiaSalaryStrategy.GrossSalary = _initialGrossSalary; ISalary calculatedSalary = _australiaSalaryStrategy.Execute(); Assert.AreEqual(_salary.GrossSalary, calculatedSalary.GrossSalary); Assert.AreEqual(_salary.TaxableIncome, calculatedSalary.TaxableIncome); Assert.AreEqual(_salary.NetAnnualSalary, calculatedSalary.NetAnnualSalary); Assert.AreEqual(_salary.Deductions, calculatedSalary.Deductions); }
public CalculateDeductionItemsRespository( IEmployee employee, List <IFamilyMember> familyMembers, ISalary salary ) { _Employee = employee; _FamilyMembers = familyMembers; _Salary = salary; }
private double CalculateSalary(Employee employee) { ISalary salary = CreateSalary(employee.ContractTypeName); if (salary != null) { return(salary.CalculteAnnualSalary(employee)); } return(0); }
public BenefitDeductionRepository( IEmployee employee, List <IFamilyMember> familyMembers, ISalary salary ) { _Employee = employee; _FamilyMembers = familyMembers; _Salary = salary; }
public void ContainSuperAnnuationInTheDeductionsReport() { _australiaSalaryStrategy.GrossSalary = _initialGrossSalary; ISalary calculatedSalary = _australiaSalaryStrategy.Execute(); decimal super = (_salary.GrossSalary * (decimal)0.086758); var expectedSuperEntry = Tuple.Create <string, decimal>("Superannuation", super); ICollection <Tuple <string, decimal> > collection = calculatedSalary.Deductions as ICollection <Tuple <string, decimal> >; Assert.That(collection, Has.Member(expectedSuperEntry)); }
public void NotReturnNegativeNetAnnualSalary() { _coreSalaryStrategy.GrossSalary = 0; decimal deductionsAmount = (decimal)600; var deductionsList = new List <Tuple <string, decimal> >(); _deductionsMock.Setup(d => d.GetDeductionsReport()).Returns(deductionsList); _deductionsMock.Setup(d => d.GetTotalDeductionsAmount(It.IsAny <decimal>())).Returns(deductionsAmount); ISalary calculatedSalary = _coreSalaryStrategy.Execute(); Assert.GreaterOrEqual(calculatedSalary.NetAnnualSalary, 0); }
public ActionResult <SalaryDto> Get(int employeeId) { IEmployeeRepository EmployeeRepos = new EmployeeRepository(); IEmployee AEmployee = EmployeeRepos.GetEmployeeById(employeeId); ISalaryRepository SalaryEmployeeRepos = new SalaryRepository(AEmployee); ISalary AEmployeeSalary = SalaryEmployeeRepos.GetSalary(); var ASalaryDto = Util.Converters.SalaryConverter.Convert(AEmployeeSalary); return(ASalaryDto); }
static void Main(string[] args) { string s = "hello interfaces"; OperatingSystem os = new OperatingSystem(PlatformID.MacOSX, new Version()); MyCustomInterface pObj = new Program(); ICloneableDemo(pObj); ICloneableDemo(s); ICloneableDemo(os); Console.WriteLine("working with interfaces"); Console.WriteLine(((Program)pObj).i); try { conn = new System.Data.SqlClient.SqlConnection( "Data Source=naynish-pc\\sqlexpress; Initial Catalog=TestData; UID = sa; PWD = Bhairav@12; Integrated Security=false"); conn.Open(); ICloneableDemo(conn); } catch (Exception e) { Console.WriteLine(e.Message); } finally { conn.Close(); } IEmployeePrototype emp1 = new Employee(); emp1.ShowDetails(); Console.WriteLine(); AbstractEmployeeBaseClass[] abcArr = new AbstractEmployeeBaseClass[] { new Founder(), new VicePresident(1000, 200000), new Programmer(48090, 85000) }; foreach (AbstractEmployeeBaseClass item in abcArr) { if (item is ISalary) { //if it implements ISalary then checking what specific type implements ISalary and filling the dictionary //with more entries if (item is VicePresident) { ((VicePresident)item).Dictionary.Add(1001, 250000); ((VicePresident)item).Dictionary.Add(1002, 300000); } else if (item is Programmer) { //Programmer implements the ISalary interface explicitly //so call the members with the reference of the interface ((ISalary)item).Dictionary.Add(48091, 90000); ((ISalary)item).Dictionary.Add(48092, 95000); InterfacesAsReturnValues().Dictionary.Add(48093, 120000); } ((ISalary)item).ShowSalaryDetails(); } else { Console.WriteLine(item.GetType() + " please implement ISalary interface"); } } ISalary[] arrSal = new ISalary[] { new My(90, 38000), new VicePresident(91, 90000), new Programmer(92, 65000) }; Console.WriteLine("\narray of interfacess"); foreach (ISalary item in arrSal) { item.ShowSalaryDetails(); } NameClash nc = new NameClash(); //nc.Display(); //call display with any interface's reference, shared Display() logic would be called. //since explicitly implemented interface members are private they are no longer available from object level //use interface reference ((IDisplayConsole)nc).Display(); ((IDisplayWebForms)nc).Display(); Console.WriteLine("\n"); EnumerableType et = new EnumerableType(); foreach (Product item in et) { Console.WriteLine("Id: {0}, Name: {1}, Price: {2}",item.Id, item.Name, item.Price); } //manually working with IEnumerator Console.WriteLine("\nmanual IEnumerator"); IEnumerable ieTr = new EnumerableType(); IEnumerator ieColl = ieTr.GetEnumerator(); for (int i = 0; i < ((EnumerableType)ieTr).arrProd.Length; i++) { ieColl.MoveNext(); Console.WriteLine("Id: {0}, Name: {1}, Price: {2}", ((Product)ieColl.Current).Id, ((Product)ieColl.Current).Name, ((Product)ieColl.Current).Price); } Console.WriteLine("\nnamed iterators"); //working with named iterators foreach (Product item in ((EnumerableType)ieTr).WorkingWithNamedIterators()) { Console.WriteLine("Id: {0}, Name: {1}, Price: {2}", item.Id, item.Name, item.Price); } //MyCustomCollection Console.WriteLine("\nMyCustomCollection"); IEnumerable ieMy = new MyCustomCollection(); foreach (KeyValuePair<Object, Object> item in ieMy) { Console.WriteLine("key: {0}, value: {1}", item.Key, item.Value); } Object[] valCollectionSave = new Object[((Dictionary<Object, Object>.ValueCollection)((MyCustomCollection)ieMy).DisplayJustValues()).Count]; ((Dictionary<Object, Object>.ValueCollection)((MyCustomCollection)ieMy).DisplayJustValues()).CopyTo(valCollectionSave, 0); foreach (Object item in valCollectionSave) { Console.WriteLine("value: {0}", item); } Console.WriteLine("\ndictionary using foreach"); foreach (KeyValuePair<Object, Object> item in ((MyCustomCollection)ieMy).UsingForeachInternally()) { Console.WriteLine("key: {0}, value: {1}", item.Key, item.Value); } //shallow copy BitmapPoint point1 = new BitmapPoint(100.12, 200.36, 300.89); BitmapPoint point2 = point1; //internal values types have an independent copy point2.x = 1000; point2.y = 2000; //internal reference is copied and now both of them point to the same memory location point2.internalRef.StartPoint = 5000; Console.WriteLine("\npoint1" + point1); Console.WriteLine("\npoint2" + point2); //deep copy: created a new instance of BitmapPoint and did a member by member independent copy BitmapPoint p1DeepCopy = new BitmapPoint(10.46, 20.89, 45.00); BitmapPoint p2DeepCopy = (BitmapPoint)(((ICloneable)p1DeepCopy).Clone()); //(BitmapPoint)p1DeepCopy.ShallowCopy(); //if you want to perform a shallow copy p2DeepCopy.x = 100; p2DeepCopy.y = 200; p2DeepCopy.internalRef.StartPoint = 50; Console.WriteLine("\npoint1 deep copy: " + p1DeepCopy); Console.WriteLine("\npoint2 deep copy: " + p2DeepCopy); ComparableFruit[] arrFruit = new ComparableFruit[] { new ComparableFruit("apple", 45), new ComparableFruit("mango", 23), new ComparableFruit("watermelon", 60), new ComparableFruit("banana", 12), new ComparableFruit("cherry", 67) }; Array.Sort(arrFruit); foreach (ComparableFruit item in arrFruit) { Console.WriteLine("fruit: {0}, price: {1}", item.Name, item.Price); } Console.WriteLine("\nMultiple Sort Orders - Sort by fruit name"); //implement each class for each sort order Array.Sort(arrFruit, new SortByName()); foreach (ComparableFruit item in arrFruit) { Console.WriteLine("fruit: {0}, price: {1}", item.Name, item.Price); } Console.WriteLine("\nMultiple Sort Orders - Sort by fruit price"); Array.Sort(arrFruit, new SortByPrice()); foreach (ComparableFruit item in arrFruit) { Console.WriteLine("fruit: {0}, price: {1}", item.Name, item.Price); } Console.WriteLine("\n"); Array.Sort(arrFruit, ComparableFruit.SortOrder(ComparableFruit.SortBy.FruitName)); foreach (ComparableFruit item in arrFruit) { Console.WriteLine("fruit: {0}, price: {1}", item.Name, item.Price); } Console.WriteLine("\n"); Array.Sort(arrFruit, ComparableFruit.SortOrder(ComparableFruit.SortBy.FruitPrice)); foreach (ComparableFruit item in arrFruit) { Console.WriteLine("fruit: {0}, price: {1}", item.Name, item.Price); } //last sorting using a readonly property Console.WriteLine("\nreadonly sort"); Array.Sort(arrFruit, ComparableFruit.SortByName); foreach (ComparableFruit item in arrFruit) { Console.WriteLine("fruit: {0}, price: {1}", item.Name, item.Price); } Console.ReadLine(); }