public ActionResult <TimeCards> AddNew(int employeeID, string PunchType, string TimeCode) { var item = new TimeCards(employeeID); item.PunchType = PunchType; item.TimeCode = TimeCode; _timeCardRepository.TimeCard.Add(item); _timeCardRepository.SaveChanges(); return(Accepted()); }
public void AddEntry(clsTimeEntry newEntry) { using (TimeCardContext context = new TimeCardContext()) { newEntry.DateTimeLastMaint = DateTime.Now.Date; context.TimeCardEntries.Add(newEntry); context.SaveChanges(); } }
public void AddTimeCard(TimeCardDTO timeCard) { using (var context = new TimeCardContext()) { context.TimeCards.Add(timeCard.ToDomain(true)); context.SaveChanges(); } }
public void AddEmployee(EmployeeDTO employee) { using (var context = new TimeCardContext()) { context.Employees.Add(employee.ToDomain(true)); context.SaveChanges(); } }
public ActionResult Delete(int id, FormCollection collection) { var db = new TimeCardContext(); var employee = db.Employees.Find(id); db.Employees.Remove(employee); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Employee newEmployee) { if (ModelState.IsValid) { var db = new TimeCardContext(); db.Employees.Add(newEmployee); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(newEmployee)); }
public ActionResult Edit(Employee updatedEmployee) { if (ModelState.IsValid) { var db = new TimeCardContext(); db.Entry(updatedEmployee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(updatedEmployee)); }
public void DeleteEntry(clsTimeEntry entryToDelete) { using (TimeCardContext context = new TimeCardContext()) { clsTimeEntry entry = context.TimeCardEntries.FirstOrDefault(e => e.EntryID == entryToDelete.EntryID); if (entry == null) { throw new Exception(string.Format("Entry for EntryID \"{0}\" was not found.", entryToDelete)); } context.TimeCardEntries.Remove(entry); context.SaveChanges(); } }
public void UpdateEntry(clsTimeEntry updatedEntry) { using (TimeCardContext context = new TimeCardContext()) { DbEntityEntry <clsTimeEntry> entry = context.Entry(updatedEntry); if (entry == null) { context.TimeCardEntries.Attach(updatedEntry); entry = context.Entry(updatedEntry); } entry.State = EntityState.Modified; context.SaveChanges(); } }