public EmployeeInformationEntity(string firstName, string lastName, string annualSalary, string superRate, string paymentPeriod) : base(firstName, lastName) { try { AnnualSalary = double.Parse(annualSalary); } catch (FormatException) { throw new InvalidPayslipException("Annual Salary needs to be a number!"); } catch (ArgumentOutOfRangeException) { throw new InvalidPayslipException("Annual Salary is too high or low!"); } if (AnnualSalary < 0) { throw new InvalidPayslipException("AnnualSalary is negative!"); } superRate = superRate.Replace("%", ""); try { SuperRate = double.Parse(superRate); } catch (FormatException) { throw new InvalidPayslipException("SuperRate needs to be a number!"); } if (SuperRate < 0 || 100 < SuperRate) { throw new InvalidPayslipException("AnnualSalary must be between 0 - 100%!"); } try { PaymentPeriod = ParsePayPeriod(paymentPeriod); } catch (FormatException) { throw new InvalidPayslipException("PaymentPeriod is not formatted correctly!"); } }
public PayslipEntity(string firstName, string lastName, PayPeriod payPeriod, double grossIncome, double incomeTax, double netIncome, double superAnnuation) { FirstName = firstName; LastName = lastName; PayPeriod = payPeriod; GrossIncome = grossIncome; IncomeTax = incomeTax; NetIncome = netIncome; SuperAnnuation = superAnnuation; }
public override bool Equals(object obj) { var item = obj as PayslipEntity; if (item == null) { return(false); } return(FirstName.Equals(item.FirstName) && LastName.Equals(item.LastName) && PayPeriod.Equals(item.PayPeriod) && GrossIncome.Equals(item.GrossIncome) && IncomeTax.Equals(item.IncomeTax) && NetIncome.Equals(item.NetIncome) && SuperAnnuation.Equals(item.SuperAnnuation)); }