public ActionResult SubmitTimeSheet(TimeTrackerVM model) { if (ModelState.IsValidField("NewTimesheet.TotalHoursByDay") && (DateTime.Now > model.NewTimesheet.DateOfTimesheet) && (model.NewTimesheet.DateOfTimesheet > new DateTime(2005, 08, 07))) { var ops = new TimeTrackerOperations(); model.NewTimesheet.EmpId = model.SelectedEmployee.EmpID; ops.SubmitTimeSheet(model.NewTimesheet); return(RedirectToAction("TimeTrackerSummary", new { empId = model.NewTimesheet.EmpId })); } ModelState.AddModelError("NewTimesheet.DateOfTimesheet", "That is an invalid date"); model.EmployeeInfo = GenerateEmployeeList(); return(View(model)); }
public void SubmitTimeSheetTest() { TimeTrackerOperations ops = new TimeTrackerOperations(); var timesheet = new Timesheet() { DateOfTimesheet = new DateTime(1989, 07, 01), EmpId = 1, TotalHoursByDay = 12 }; ops.SubmitTimeSheet(timesheet); var repo = new TimeTrackerRepository(); List <Timesheet> listOfSheets = repo.GetAllTimeSheets(1); Assert.AreEqual(6, listOfSheets.Count); }