Пример #1
0
        //[ApiVersion("1.1")]
        //[Authorize(Roles = "teacher")]
        public async Task <ActionResult> Insert(CourseInsertRequest course)
        {
            //StudentRequest students = new StudentRequest();
            var courses = await _service.AddCourseAsync(course);

            return(Ok(courses));
        }
Пример #2
0
        public async Task <Course> AddCourseAsync(CourseInsertRequest request)
        {
            var course = new Course
            {
                Code = request.Code,
                Name = request.Name
            };
            await _unitOfWork.CourseRepository.createAsync(course);

            if (await _unitOfWork.ApplicationSaveChangesAsync())
            {
                return(course);
            }
            throw new MyAppException("Something went wrong");
        }
Пример #3
0
        public async Task <Course> AddCourseAsync(CourseInsertRequest request)
        {
            Course course = new Course()
            {
                Code = request.Code,
                Name = request.Name
            };

            await unitOfWork.CourseRepository.InsertAsync(course);

            if (await unitOfWork.DbSaveChangeAsync() == true)
            {
                return(course);
            }
            throw new ExceptionManagementHelper("Data Insert Unsuccessfully");
            // return await unitOfWork.CourseRepository.InsertAsync(course);
        }
Пример #4
0
        public async Task <Course> AddCourseAsync(CourseInsertRequest request)
        {
            Course course = new Course()
            {
                Code = request.Code,
                Name = request.Name
            };

            await _unitOfWork.CourseRepository.CreateAsync(course);

            if (await _unitOfWork.ApplicationSaveChangesAsync())
            {
                return(course);
            }
            throw new MyAppException("Data Insert Unsuccessfully");
            // return await _unitOfWork.CourseRepository.InsertAsync(course);
        }
Пример #5
0
        public async Task <Course> UpdateCourseAsync(string code, CourseInsertRequest course)
        {
            var objcourse = await unitOfWork.CourseRepository.GetSingleAsync(x => x.Code == code);

            if (objcourse == null)
            {
                throw new ExceptionManagementHelper("No found Data");
            }

            objcourse.Name = course.Name;

            unitOfWork.CourseRepository.Update(objcourse);


            if (await unitOfWork.DbSaveChangeAsync())
            {
                return(objcourse);
            }
            throw new ExceptionManagementHelper("Student Data Not save");
        }
Пример #6
0
        public async Task <Course> UpdateCourseAsync(string code, CourseInsertRequest course)
        {
            var objcourse = await _unitOfWork.CourseRepository.GetAAsynce(x => x.Code == code);

            if (objcourse == null)
            {
                throw new MyAppException("No found Data");
            }

            objcourse.Name = course.Name;

            _unitOfWork.CourseRepository.UpdateAsyc(objcourse);


            if (await _unitOfWork.ApplicationSaveChangesAsync())
            {
                return(objcourse);
            }
            throw new MyAppException("Student Data Not save");
        }
Пример #7
0
 //[Authorize(Roles = "staff")]
 public async Task <ActionResult> Update(string code, CourseInsertRequest request)
 {
     return(Ok(await _service.UpdateCourseAsync(code, request)));
 }
Пример #8
0
 public async Task <ActionResult> AddADepartment(CourseInsertRequest course)
 {
     return(Ok(await _courseService.AddCourseAsync(course)));
 }