Beispiel #1
0
 public Employee(string firstName, string lastName, int experience, string department, int cost = 1000, int biweeklySalary = 2000)
 {
     FirstName      = firstName;
     LastName       = lastName;
     Experience     = experience;
     Department     = department;
     Cost           = cost;
     BiweeklySalary = biweeklySalary;
     DiscountFactor = DeductionHelpers.CalculateDiscountFactor(firstName);
 }
        public async Task <ActionResult <Dependent> > CreateEmployee(Dependent dependent)
        {
            dependent.Cost           = 500;
            dependent.DiscountFactor = DeductionHelpers.CalculateDiscountFactor(dependent
                                                                                .FirstName);
            _context.Dependents.Add(dependent);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetDependent), new { id = dependent.DependentId }, dependent));
        }
Beispiel #3
0
        public async Task <ActionResult <Employee> > CreateEmployee(Employee employee)
        {
            employee.BiweeklySalary = 2000;
            employee.Cost           = 1000;
            employee.DiscountFactor = DeductionHelpers.CalculateDiscountFactor(employee.FirstName);
            _context.Employees.Add(employee);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetEmployee), new { id = employee.EmployeeId }, employee));
        }
        public DependentController(AzureDatabaseContext context)
        {
            _context = context;

            if (_context.Dependents.Count() == 0)
            {
                _context.Dependents.Add(new Dependent
                {
                    DependentId    = 1,
                    EmployeeId     = 1,
                    FirstName      = "DeAnna",
                    LastName       = "Gross",
                    Cost           = 500,
                    DiscountFactor = DeductionHelpers.CalculateDiscountFactor("DeAnna")
                });
                _context.SaveChanges();
            }
        }