Exemplo n.º 1
0
        public EmployeeEditViewModel(WorkforceContext ctx, int employeeId)
        {
            // Select list for departments
            this.Departments = ctx.Department
                               .OrderBy(l => l.Name)
                               .AsEnumerable()
                               .Select(li => new SelectListItem {
                Text  = li.Name,
                Value = li.DepartmentId.ToString()
            }).ToList();

            // Add a prompt so that the <select> element isn't blank for a new employee
            this.Departments.Insert(0, new SelectListItem {
                Text  = "Choose department...",
                Value = "0"
            });

            // Build a list of training sessions that begin in the future
            List <Training> availableSessions = ctx.Training
                                                .Where(t => t.StartDate > DateTime.Now)
                                                .ToList();

            // Build a list of training program ids to pre-select in the multiselect element
            var goingToList = (
                from t in ctx.Training
                join et in ctx.EmployeeTraining on t.TrainingId equals et.TrainingId
                where et.EmployeeId == employeeId
                select t.TrainingId
                ).ToList();

            /*
             *  This MultiSelectList constructor takes 4 arguments. Here's what they all mean.
             *      1. The collection that store all items I want in the <select> element
             *      2. The column to use for the `value` attribute
             *      3. The column to use for display text
             *      4. A list of integers for ones to be pre-selected
             */
            this.Sessions = new MultiSelectList(availableSessions, "TrainingId", "Title", goingToList);
        }
 public EmployeesController(WorkforceContext ctx)
 {
     context = ctx;
 }
Exemplo n.º 3
0
 public EmployeeController(WorkforceContext context)
 {
     _context = context;
 }
 public TrainingProgramsController(WorkforceContext ctx)
 {
     context = ctx;
 }
 public EmployeeSkillRepository(WorkforceContext workforceContext)
 {
     _workforceDbContext = workforceContext ?? throw new ArgumentNullException();
     _workforceDbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
 }
 public DepartmentsController(WorkforceContext ctx)
 {
     context = ctx;
 }
 public TrainingController(WorkforceContext context)
 {
     _context = context;
 }
 public WorkerRepository()
 {
     _workforceContext = new WorkforceContext();
 }
 public DepartmentController(WorkforceContext context)
 {
     _context = context;
 }
Exemplo n.º 10
0
 public ComputersController(WorkforceContext ctx)
 {
     context = ctx;
 }