Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
 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();
            }
        }
Ejemplo n.º 5
0
        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"));
        }
Ejemplo n.º 6
0
 public ActionResult Create(Employee newEmployee)
 {
     if (ModelState.IsValid)
     {
         var db = new TimeCardContext();
         db.Employees.Add(newEmployee);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newEmployee));
 }
Ejemplo n.º 7
0
 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));
 }
Ejemplo n.º 8
0
 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();
     }
 }
Ejemplo n.º 9
0
 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();
     }
 }