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 async Task <bool> CreateCourse(Course course) { course.RowId = Guid.NewGuid().ToString(); _dbContext.Add(course); try { await _dbContext.SaveChangesAsync(); return(true); } catch (DbUpdateException) { return(false); } }