Пример #1
0
        public async Task <bool> ChangeCompleteStatus(int id)
        {
            var employeeCourse = await _dbContext.EmployeeCourses.FindAsync(id);

            if (employeeCourse == null)
            {
                return(false);
            }

            employeeCourse.UpdatedOn  = DateTime.Now;
            employeeCourse.isComplete = !employeeCourse.isComplete;
            if (employeeCourse.isComplete)
            {
                employeeCourse.CompletedOn = DateTime.Now;
            }
            //else
            //{
            //    employeeCourse.CompletedOn = null;
            //}

            _dbContext.Entry(employeeCourse).State = EntityState.Modified;
            await _dbContext.SaveChangesAsync();

            return(true);
        }
Пример #2
0
        public async Task <bool> EditCourse(string id, Course course)
        {
            int _id = int.Parse(id);

            if (_id != course.CourseID)
            {
                return(false);
            }

            _dbContext.Entry(course).State = EntityState.Modified;
            await _dbContext.SaveChangesAsync();

            return(true);
        }
Пример #3
0
        public async Task <bool> EditEmployee(string id, Employee employee)
        {
            int _id = int.Parse(id);

            if (_id != employee.EmployeeID)
            {
                return(false);
            }

            _dbContext.Entry(employee).State = EntityState.Modified;
            await _dbContext.SaveChangesAsync();

            return(true);
        }