Exemple #1
0
        public IList <EmployeeModel> GetAll()
        {
            var                  employees = _EmployeeRepository.GetAll().ToList();
            IPayment             payment   = null;
            List <EmployeeModel> models    = new List <EmployeeModel>();

            foreach (var employee in employees)
            {
                var model = Mapper.Map <EmployeeModel>(employee);

                payment            = _paymentFactory.CreatePayment(employee);
                model.AnnualSalary = payment.CalculateAnnualSalary(employee);

                models.Add(model);
            }

            return(models);
        }
Exemple #2
0
        public EmployeeModel Get(int Id)
        {
            var employee = _EmployeeRepository.GetAll().Where(e => e.Id.Equals(Id)).FirstOrDefault();

            if (employee != null)
            {
                IPayment      payment = null;
                EmployeeModel model   = new EmployeeModel();
                model = Mapper.Map <EmployeeModel>(employee);

                payment            = _paymentFactory.CreatePayment(employee);
                model.AnnualSalary = payment.CalculateAnnualSalary(employee);

                return(model);
            }
            else
            {
                return(null);
            }
        }