public virtual bool addHours(Hours newhours) { Authentication auth = new Authentication(); if (auth.isUser(this) || Authentication.DEBUG_bypassAuth) { WorkEffort tmpWe = WorkEffortDB.WorkEffortList.Find(newhours.workEffortID); //make sure that the new hours are within the work effort's time bounds if ((newhours.timestamp < tmpWe.startDate) || (newhours.timestamp > tmpWe.endDate)) { return false; } //make sure that a timesheet exists for the period hours are being added to checkForTimesheet(newhours.creator, newhours.timestamp); //add and save new hours HoursDB.HoursList.Add(newhours); HoursDB.SaveChanges(); return true; } else { return false; } }
public virtual ActionResult managerEditHours(Hours tmpHours) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { if (ModelState.IsValid) { HoursDB.Entry(tmpHours).State = EntityState.Modified; HoursDB.SaveChanges(); } int userKeyID = getUserKeyID(tmpHours.creator); return RedirectToAction("approveTimesheet", new { userKeyID = userKeyID, tsDate = tmpHours.timestamp }); } else { return View("error"); } }