public ActionResult SummaryPage(int id) { var timeRepo = new TimesheetDatabase(); var empRepo = new EmployeeDatabase(); var input = new SummaryPageVM(); input.Employee = empRepo.GetById(id); input.Timesheets = timeRepo.GetByEmpId(id); return View(input); }
public ActionResult DeleteTimesheet(int timeId) { var timeRepo = new TimesheetDatabase(); var empRepo = new EmployeeDatabase(); var toDelete = timeRepo.GetByTimesheetId(timeId); var employeeToDock = empRepo.GetById(toDelete.EmployeeId); var hoursToDock = toDelete.HoursWorked*-1; timeRepo.Delete(toDelete); empRepo.AddHours(employeeToDock, hoursToDock); return RedirectToAction("SummaryPage", new {id = employeeToDock.Id}); }
public ActionResult Index(EmployeeTimesheetVM submitted) { var empRepo = new EmployeeDatabase(); var timeRepo = new TimesheetDatabase(); var employee = empRepo.GetById(submitted.Employee.Id); submitted.Timesheet.EmployeeId = submitted.Employee.Id; if (ModelState.IsValid) { empRepo.AddHours(employee, submitted.Timesheet.HoursWorked); timeRepo.Add(submitted.Timesheet); return RedirectToAction("SummaryPage", "ViewTimesheet", new {id = submitted.Employee.Id}); } return View("Index", submitted); }