Esempio n. 1
0
 public Dependent Create(int organizationId, int employeeId, Dependent dependent)
 {
     if (_employeeLogic.Get(organizationId, employeeId) == null)
     {
         return(null);
     }
     else
     {
         dependent.EmployeeId = employeeId;
         _dataContext.Dependents.Add(dependent);
         _dataContext.SaveChanges();
         return(dependent);
     }
 }
Esempio n. 2
0
        public List <PaySummaryItem> GetPaySummary(int organizationId, int employeeId)
        {
            var org     = _oLogic.Get(organizationId);
            var emp     = _eLogic.Get(organizationId, employeeId);
            var deps    = _dLogic.GetAll(organizationId, employeeId);
            var summary = new List <PaySummaryItem>();

            //Add the gross pay
            summary.Add(new PaySummaryItem()
            {
                Item     = "Gross Pay",
                Subtotal = emp.GrossPay
            });

            //Subtract out benefits
            decimal employeeBenefits = org.EmployeeBenefitsCost / org.PaychecksPerYear;

            summary.Add(new PaySummaryItem()
            {
                Item     = string.Format("Employee Benefits - {0} {1}", emp.FirstName, emp.LastName),
                Subtotal = -employeeBenefits,
                Discount = _discountLogic.Calculate(emp, employeeBenefits)
            });

            deps.ForEach(d =>
            {
                decimal dependentBenefits = org.DependentBenefitsCost / org.PaychecksPerYear;
                summary.Add(new PaySummaryItem()
                {
                    Item     = string.Format("Dependent Benefits - {0} {1}", d.FirstName, d.LastName),
                    Subtotal = -dependentBenefits,
                    Discount = _discountLogic.Calculate(d, dependentBenefits)
                });
            });

            //Add the total item
            summary.Add(new PaySummaryItem()
            {
                Item     = "Total",
                Subtotal = summary.Sum(s => s.Subtotal),
                Discount = summary.Sum(s => s.Discount)
            });


            return(summary);
        }