Esempio n. 1
0
        static void Main(string[] args)
        {
            Parser.Default.ParseArguments <Options>(args).WithParsed(o =>
            {
                Console.WriteLine("Running salary calculator with parameters:");
                Console.WriteLine($"File path: {o.FilePath}");
                Console.WriteLine($"Salary date: {o.SalaryDate.ToShortDateString()}");
                Console.WriteLine("---------------------------------------------------------");

                if (!File.Exists(o.FilePath))
                {
                    Console.WriteLine($"File {o.FilePath} is missing.");
                    return;
                }

                var provider  = new EmployeeProvider(new FileJsonEmployeeDataProvider(o.FilePath));
                var employees = provider.GetEmployees();
                Console.WriteLine($"Company with {employees.Count()} persons was loaded:");

                foreach (var person in employees)
                {
                    Console.WriteLine($"{person.Name} with salary {person.GetSalaryByDate(o.SalaryDate)}");
                }

                Console.WriteLine($"Total: {employees.Sum(e => e.GetSalaryByDate(o.SalaryDate))}");
            });
        }
Esempio n. 2
0
        public ActionResult GetEmployees()
        {
            var employee = employeeProvider.GetEmployees();

            return(View(employee));
        }