Ejemplo n.º 1
0
        public async Task <IActionResult> Create(EmployeeEditModel editModel)
        {
            var employeeToAdd = new Employee
            {
                Name    = editModel.Name,
                Surname = editModel.Surname
            };

            _context.Add(employeeToAdd); // EntityState.Added
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(TimeEntryEditModel editModel)
        {
            var timeEntryToAdd = new TimeEntry
            {
                DateLogged  = editModel.DateLogged,
                HoursWorked = editModel.HoursWorked,
                EmployeeId  = editModel.EmployeeId
            };

            _context.Add(timeEntryToAdd); // EntityState.Added
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Employee"));
        }