Ejemplo n.º 1
0
        public static double GetTotalPayCheckAfterDeductions(bool discountFlag, CompanyRules rules, double employeePreimium, double dependentsPremium)
        {
            //if it take more then two steps make a seperate function for that
            var totalPreimium = employeePreimium + dependentsPremium;

            totalPreimium = discountFlag ? GetDiscount(rules.NameDiscountPercentage, totalPreimium) : totalPreimium;
            return(rules.PayCheck - totalPreimium);
        }
Ejemplo n.º 2
0
        public static EmployeeDetails ConverttoEmployeeDetail(Employee rec, CompanyRules rules)
        {
            var result = new EmployeeDetails();

            result = new EmployeeDetails
            {
                Id         = rec.Id,
                FirstName  = rec.FirstName,
                LastName   = rec.LastName,
                Dependents = rec.Dependents != null?rec.Dependents.Select(x => new DTO.Results.Info
                {
                    FirstName = x.FirstName,
                    LastName  = x.LastName
                }) : new List <DTO.Results.Info>()
            };

            result.NameDiscountFlag        = GetNameDiscountFlag(result, rules.NameDiscount);
            result.EmployeePremium         = getEmployeePremium(rules.EmployeeCost, rules.TotalPayCheck);
            result.DependentsPremium       = result.Dependents.Count() > 0 ? (GetDependendentPremium(rules.DependentCost, rules.TotalPayCheck, result.Dependents.Count())) : 0;
            result.PayCheckAfterDeductions = GetTotalPayCheckAfterDeductions(result.NameDiscountFlag, rules, result.EmployeePremium, result.DependentsPremium);

            return(result);
        }
Ejemplo n.º 3
0
        public void Setup()
        {
            var optionsBuilder = new DbContextOptionsBuilder <EmployeeContext>();

            optionsBuilder.UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString());

            _context = new EmployeeContext(optionsBuilder.Options);
            _context.Employees.AddRange(
                new Entities.Employee {
                FirstName = "Syed", LastName = "Test", Dependents = new List <Entities.Info> {
                    new Entities.Info {
                        FirstName = "Steve", LastName = "Test"
                    }
                }
            },
                new Entities.Employee {
                FirstName = "Apple", LastName = "Test", Dependents = new List <Entities.Info> {
                    new Entities.Info {
                        FirstName = "Steve", LastName = "Test"
                    }
                }
            }
                );

            _context.SaveChanges();
            var rules = new CompanyRules()
            {
                EmployeeCost           = 1000,
                DependentCost          = 500,
                NameDiscount           = "a",
                NameDiscountPercentage = 10,
                PayCheck      = 2000,
                TotalPayCheck = 26
            };

            _mockRules = Options.Create(rules);
        }