using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using System.Net; using custom.BLL.Model; using custom.DAL.EF; namespace custom.BLL { public interface IPayrollService { WeekClass GetTimeSheet(int empNo, string period, string tz); Time[] GetEntriesFromCustomDb(int empNo, DateTime fromDate, DateTime toDate); bool AddTimeEntries(WeekClass week); WeekClass ExecutePayRollRules(int empNo, string period, string tz); } public class PayrollService : IPayrollService { public WeekClass GetTimeSheet(int empNo, string period, string tz) { if (string.IsNullOrEmpty(period)) throw new ArgumentNullException("period", "A timesheet period is required."); if (!period.Contains("-")) throw new ArgumentException("The provided period is invalid. Must be formatted as mm/dd/yyyy-mm/dd/yyyy.", "period"); string[] p = period.Split('-'); List timeEntries = GetTimeEntries(empNo, DateTime.Parse(p[0]), DateTime.Parse(p[1])); // TODO - pass in these entries to be process by payroll rules var mealAndRestTimes = GetEntriesFromCustomDb(empNo, DateTime.Parse(p[0]), DateTime.Parse(p[1])); var rules = new PayrollRules(); return rules.CalculateTimeKeeper(p[0], timeEntries); } public WeekClass ExecutePayRollRules(int empNo, string period, string tz) { string[] p = period.Split('-'); List timeEntries = GetTimeEntries(empNo, DateTime.Parse(p[0]), DateTime.Parse(p[1])); var rules = new PayrollRules(); return rules.CalculateMealRestCreditRule(p[0],timeEntries); } public bool AddTimeEntries(WeekClass week) { try { var times = new List