コード例 #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());
        }
コード例 #2
0
 public void AddEntry(clsTimeEntry newEntry)
 {
     using (TimeCardContext context = new TimeCardContext())
     {
         newEntry.DateTimeLastMaint = DateTime.Now.Date;
         context.TimeCardEntries.Add(newEntry);
         context.SaveChanges();
     }
 }
コード例 #3
0
        public void AddTimeCard(TimeCardDTO timeCard)
        {
            using (var context = new TimeCardContext())
            {
                context.TimeCards.Add(timeCard.ToDomain(true));

                context.SaveChanges();
            }
        }
コード例 #4
0
        public void AddEmployee(EmployeeDTO employee)
        {
            using (var context = new TimeCardContext())
            {
                context.Employees.Add(employee.ToDomain(true));

                context.SaveChanges();
            }
        }
コード例 #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"));
        }
コード例 #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));
 }
コード例 #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));
 }
コード例 #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();
     }
 }
コード例 #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();
     }
 }