//[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)); }
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"); }
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); }
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); }
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"); }
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"); }
//[Authorize(Roles = "staff")] public async Task <ActionResult> Update(string code, CourseInsertRequest request) { return(Ok(await _service.UpdateCourseAsync(code, request))); }
public async Task <ActionResult> AddADepartment(CourseInsertRequest course) { return(Ok(await _courseService.AddCourseAsync(course))); }