public ICollection <TrainingEmployee> SetObjectInfo4TrainingEmployee()
    {
        List <TrainingEmployee> lst = new List <TrainingEmployee>();
        TrainingEmployee        _objTrainingEmployee = null;

        //int itemNo = 1;


        for (int i = 0; i < gdvTrainingEmployee.Rows.Count; i++)
        {
            CheckBox chk = new CheckBox();
            chk = (CheckBox)gdvTrainingEmployee.Rows[i].FindControl("chkSelect");
            Label EmployeeId = (Label)gdvTrainingEmployee.Rows[i].FindControl("gdvlblId");
            if (chk.Checked)
            {
                _objTrainingEmployee = new TrainingEmployee();

                _objTrainingEmployee.CreatedBy    = Session["LoginId"].ToString();
                _objTrainingEmployee.ModifiedBy   = Session["LoginId"].ToString();
                _objTrainingEmployee.EmployeeId   = EmployeeId.Text;
                _objTrainingEmployee.CreatedDate  = DateTime.Now.ToString();
                _objTrainingEmployee.ModifiedDate = DateTime.Now.ToString();
                lst.Add(_objTrainingEmployee);
            }
        }

        return(lst);
    }
Beispiel #2
0
        public virtual bool AddTrainingsToEmployee(int employeeId, List <int> trainingList)
        {
            try
            {
                IRepository <TrainingEmployee> comboRepo = new RepositoryFactory().Create <TrainingEmployee>();
                foreach (int id in trainingList)
                {
                    TrainingEmployee item = new TrainingEmployee();
                    item.EmployeeId = employeeId;
                    item.TrainingId = id;

                    comboRepo.Insert(item);
                }

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine("Encountered error while adding employees to training: " + e);
                return(false);
            }
        }
Beispiel #3
0
        public virtual async Task <bool> AddEmployeesToTrainingProgram(int trainingId, List <int> employeeIdList)
        {
            try
            {
                TrainingEmployeeRepository comboRepo = new TrainingEmployeeRepository();
                foreach (int id in employeeIdList)
                {
                    TrainingEmployee item = new TrainingEmployee();
                    item.TrainingId = trainingId;
                    item.EmployeeId = id;

                    await comboRepo.Insert(item);
                }

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine("Encountered error while adding employees to training: " + e);
                return(false);
            }
        }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new WorkforceContext(serviceProvider.GetRequiredService <DbContextOptions <WorkforceContext> >()))
            {
                //LOOK FOR ANY EMPLOYEE
                if (context.Employee.Any())
                {
                    return;
                }

                var employees = new Employee[]
                {
                    new Employee
                    {
                        FirstName     = "George",
                        LastName      = "Bush",
                        MiddleInitial = "W",
                        JobTitle      = "President"
                    },
                    new Employee
                    {
                        FirstName     = "Bini",
                        LastName      = "Hammer",
                        MiddleInitial = "K",
                        JobTitle      = "Cook"
                    },
                    new Employee
                    {
                        FirstName     = "James",
                        LastName      = "Bond",
                        MiddleInitial = "J",
                        JobTitle      = "Security"
                    }
                };

                foreach (Employee e in employees)
                {
                    context.Employee.Add(e);
                }


                var computers = new Computer[]
                {
                    new Computer {
                        Model         = "Lenovo",
                        PurchasePrice = 699.99
                    },
                    new Computer {
                        Model         = "Asus",
                        PurchasePrice = 499.05
                    },
                    new Computer {
                        Model         = "Mac",
                        PurchasePrice = 550.00
                    }
                };

                foreach (Computer c in computers)
                {
                    context.Computer.Add(c);
                }

                var departments = new Department[]
                {
                    new Department
                    {
                        Name        = "IT",
                        Description = "A place to make your software dreams come true!"
                    },
                    new Department
                    {
                        Name        = "Administration",
                        Description = "Bossing you around since buisness creation!"
                    },
                    new Department
                    {
                        Name        = "Human Resources",
                        Description = "Developing relationships is our specialty!"
                    }
                };

                foreach (Department d in departments)
                {
                    context.Department.Add(d);
                }

                var trainingprograms = new TrainingProgram[]
                {
                    new TrainingProgram
                    {
                        Name        = "C# For Dummies",
                        Description = "This program is for Dummies only!",
                        MaxCapacity = 500
                    },
                    new TrainingProgram
                    {
                        Name        = "Cooking For Dummies",
                        Description = "Let's bake a cake!",
                        MaxCapacity = 50
                    },
                    new TrainingProgram
                    {
                        Name        = "How to be Rich in Ten Days?",
                        Description = "Broke people only!",
                        MaxCapacity = 100
                    }
                };

                foreach (TrainingProgram tp in trainingprograms)
                {
                    context.TrainingProgram.Add(tp);
                }

                context.SaveChanges();

                var trainingemployees = new TrainingEmployee[]
                {
                    new TrainingEmployee
                    {
                        EmployeeId        = 1,
                        TrainingProgramId = 1
                    },
                    new TrainingEmployee
                    {
                        EmployeeId        = 2,
                        TrainingProgramId = 2
                    },
                    new TrainingEmployee
                    {
                        EmployeeId        = 3,
                        TrainingProgramId = 3
                    }
                };

                foreach (TrainingEmployee te in trainingemployees)
                {
                    context.TrainingEmployee.Add(te);
                }

                context.SaveChanges();
            }
        }