public Response<TimeTrackerSummary> GetTimeTrackerSummary(int empId) { TimeTrackerRepository repo = new TimeTrackerRepository(); var response = new Response<TimeTrackerSummary>(); List<Timesheet> listOfTimesheets = repo.GetAllTimeSheets(empId); try { if (listOfTimesheets.Count > 0) { response.Success = true; response.Data = new TimeTrackerSummary() { SelectedEmployee = repo.GetSingleEmployee(empId), TotalHoursWorked = repo.TotalHoursWorked(empId), AllTimesheets = listOfTimesheets }; } else { response.Data = new TimeTrackerSummary() { SelectedEmployee = repo.GetSingleEmployee(empId), }; response.Success = false; response.Message = "There were no timesheets found for that employee"; } } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return response; }
public void TotalHoursWorkedTest() { var repo = new TimeTrackerRepository(); int totalHoursWorked = repo.TotalHoursWorked(6); Assert.AreEqual(22, totalHoursWorked); }