Esempio n. 1
0
        public async Task <bool> CreateEmployee(Employee employee)
        {
            // List<EmployeeCourse> employeeCourseList = new List<EmployeeCourse>();

            employee.RowId = Guid.NewGuid().ToString();
            _dbContext.Add(employee);

            try
            {
                await _dbContext.SaveChangesAsync();

                for (int i = 3; i < 8; i++)
                {
                    EmployeeCourse employeeCourse = new EmployeeCourse();
                    employeeCourse.EmployeeID = employee.EmployeeID;
                    employeeCourse.isComplete = false;
                    employeeCourse.CourseID   = i;
                    _dbContext.Add(employeeCourse);
                }


                await _dbContext.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateException)
            {
                return(false);
            }
        }
        public IActionResult SaveEmployeeCourse(EmployeeCourse employeeCourse)
        {
            employeeCourse.EmployeeId = GetCurrentEmployee().Id;
            this.employeeCourseService.Create(employeeCourse);

            return(RedirectToAction("ProfileEducations"));
        }
Esempio n. 3
0
        public bool EnrollEmployeeToCourse(int employeeId, int courseId)
        {
            Employee ExistingEmployee = _employeeRepository.FindById(employeeId);
            Course   ExistingCourse   = _courseRepository.FindById(courseId);

            if (ExistingEmployee == null || ExistingCourse == null)
            {
                return(false);
            }

            EmployeeCourse employeeCourse = new EmployeeCourse
            {
                CourseId   = courseId,
                EmployeeId = employeeId
            };

            _employeeCourseRepository.Create(employeeCourse);
            _employeeCourseRepository.SaveChanges();

            ExistingEmployee.EmployeeCourses.Add(employeeCourse);
            _employeeRepository.Update(ExistingEmployee);
            _employeeRepository.SaveChanges();

            ExistingCourse.EmployeeCourses.Add(employeeCourse);
            _courseRepository.Update(ExistingCourse);
            _courseRepository.SaveChanges();
            return(true);
        }
        public async Task CreateEmployeeCourse(int courseId, int userId, int status, DateTime dateCreated)
        {
            EmployeeCourse employeeCourse = new EmployeeCourse
            {
                CourseId    = courseId,
                UserID      = userId,
                Status      = status,
                DateCreated = dateCreated
            };

            _context.EmployeeCourses.Add(employeeCourse);
            await _context.SaveChangesAsync();
        }
Esempio n. 5
0
        public async Task <IActionResult> Update([FromBody] EmployeeCourse employeeCourse)
        {
            int result = 0;

            try
            {
                context.Update(employeeCourse);
                result = await context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                logger.LogError(ex.ToString());
            }
            return(Ok(result));
        }
        public async Task <bool> CreateEmployeeCource(EmployeeCourse employeecource)
        {
            // employeecource.RowId = Guid.NewGuid().ToString();
            _dbContext.Add(employeecource);
            try
            {
                await _dbContext.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateException)
            {
                return(false);
            }
        }
Esempio n. 7
0
        public async Task <IActionResult> Save([FromBody] EmployeeCourse employeeCourse)
        {
            int result = 0;

            try
            {
                employeeCourse.EmployeeCourseId = Guid.NewGuid();
                context.Add(employeeCourse);
                result = await context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                logger.LogError(ex.ToString());
            }
            return(Ok(result));
        }
Esempio n. 8
0
        public bool Enroll(Employee employee, Course course)
        {
            var isAlreadyEnrolled = IsAlreadyEnrolled(employee.Id, course.Id);

            if (!isAlreadyEnrolled)
            {
                var employeeEnrollment = new EmployeeCourse
                {
                    CourseId   = course.Id,
                    EmployeeId = employee.Id,
                    Mark       = 0
                };
                _context.EmployeeCourses.Add(employeeEnrollment);
                var result = _context.SaveChanges();
                return(result > 0);
            }
            return(false);
        }
 public Task <bool> CreateEmployeeCourse(EmployeeCourse employeecourse)
 {
     throw new NotImplementedException();
 }