public ActionResult DeleteConfirmed(int id) { WorkTimes workTimes = db.WorkTimes.Find(id); db.WorkTimes.Remove(workTimes); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,WorksId,StartTime,EndTime,WorkHours,OvettimeHours,AheadMinutes,BackMinutes,LateMinutes,LeaveEarlyMinutes,IsAheadToOvertime,IsBackToOvertime")] WorkTimes workTimes) { if (ModelState.IsValid) { db.Entry(workTimes).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(workTimes)); }
public ActionResult Create([Bind(Include = "Id,WorksId,StartTime,EndTime,WorkHours,OvettimeHours,AheadMinutes,BackMinutes,LateMinutes,LeaveEarlyMinutes,IsAheadToOvertime,IsBackToOvertime")] WorkTimes workTimes) { if (ModelState.IsValid) { db.WorkTimes.Add(workTimes); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.WorksId = new SelectList(db.Works, "Id", "Name", workTimes.WorksId); return(View(workTimes)); }
// GET: WorkTimes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WorkTimes workTimes = db.WorkTimes.Find(id); if (workTimes == null) { return(HttpNotFound()); } return(View(workTimes)); }
public ActionResult WorkTimesEdit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WorkTimes workTimes = db.WorkTimes.Find(id); if (workTimes == null) { return(HttpNotFound()); } ViewBag.WorkId = workTimes.WorksId; return(View(workTimes)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WorkTimes workTimes = db.WorkTimes.Find(id); ViewBag.WorkId = workTimes.WorksId; if (workTimes == null) { return(HttpNotFound()); } ViewBag.WorksId = new SelectList(db.Works, "Id", "Name", workTimes.WorksId); return(View(workTimes)); }
public ActionResult WorkTimesCreate(WorkTimes workTimes) { if (ModelState.IsValid) { workTimes.WorksId = int.Parse(Request["WorkId"]); db.WorkTimes.Add(workTimes); db.SaveChanges(); Works tmp = db.Works.Find(workTimes.WorksId); tmp.TotalWorkHours += workTimes.WorkHours; tmp.TotalOvertimeHours += workTimes.OvettimeHours; db.Entry(tmp).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("WorkTimesIndex", new { id = workTimes.WorksId })); } return(View(workTimes)); }
public ActionResult WorkTimesDeleteConfirmed(FormCollection collection) { WorkTimes workTimes = db.WorkTimes.Find(int.Parse(collection["Id"])); int WorkId = workTimes.WorksId; db.WorkTimes.Remove(workTimes); db.SaveChanges(); Works tmp = db.Works.Find(workTimes.WorksId); List <WorkTimes> workHours = db.WorkTimes.Where(p => p.WorksId == workTimes.WorksId).ToList(); tmp.TotalWorkHours = 0; tmp.TotalOvertimeHours = 0; foreach (WorkTimes tmpInt in workHours) { tmp.TotalWorkHours += tmpInt.WorkHours; tmp.TotalOvertimeHours += tmpInt.OvettimeHours; } db.Entry(tmp).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("WorkTimesIndex", new { id = WorkId })); }
public ActionResult WorkTimesEdit([Bind(Include = "Id,WorksId,StartTime,EndTime,WorkHours,OvettimeHours,AheadMinutes,BackMinutes,LateMinutes,LeaveEarlyMinutes,IsAheadToOvertime,IsBackToOvertime")] WorkTimes workTimes) { if (ModelState.IsValid) { db.Entry(workTimes).State = EntityState.Modified; db.SaveChanges(); Works tmp = db.Works.Find(workTimes.WorksId); List <WorkTimes> workHours = db.WorkTimes.Where(p => p.WorksId == workTimes.WorksId).ToList(); tmp.TotalWorkHours = 0; tmp.TotalOvertimeHours = 0; foreach (WorkTimes tmpInt in workHours) { tmp.TotalWorkHours += tmpInt.WorkHours; tmp.TotalOvertimeHours += tmpInt.OvettimeHours; } db.Entry(tmp).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("WorkTimesIndex", new { id = workTimes.WorksId })); } return(View(workTimes)); }
public WorkingTimePeriodViewModel(WorkingTimePeriod period) { Till = period.Till; period.Times.ForEach(r => WorkTimes.Add(r)); }