예제 #1
0
        public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,DisplayName")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
        public async Task <IActionResult> Create(int id, DateTime timeIn, DateTime timeOut, int employeeId)
        {
            TimeSheet timeSheet = new TimeSheet
            {
                ID          = id,
                TimeIn      = timeIn,
                TimeOut     = timeOut,
                HoursWorked = timeOut - timeIn,
                EmployeeID  = employeeId
            };

            if (ModelState.IsValid)
            {
                _context.Add(timeSheet);
                await _context.SaveChangesAsync();

                return(Redirect($"Details/{timeSheet.ID}"));
            }
            ViewData["EmployeeID"] = new SelectList(_context.Employees, "ID", "DisplayName", timeSheet.EmployeeID);
            return(View(timeSheet));
        }
예제 #3
0
 public void Insert(Employee E)
 {
     DbContext.Add(E);
     DbContext.SaveChanges();
 }
예제 #4
0
 public void Insert(Task T)
 {
     DbContext.Add(T);
     DbContext.SaveChanges();
 }