/* public async Task<PagedResultDto<GetAllCourseOutputDto>> GetAllCourseOfTeacher(GetAllCourseInput input) * { * var a = WorkScope.GetAll<Course>().WhereIf(!input.NameOfCourse.IsNullOrWhiteSpace(), s => s.Title.Contains(input.NameOfCourse)) * .Where(s => s.IsDeleted == false) * .WhereIf(input.UserID.HasValue, s => s.UserId == input.UserID) * .Select(s => new GetAllCourseOutputDto * { * Id = s.Id, * Creator = s.Creator.FullName, * DateCreator = s.CreationTime, * LastModify = s.LastModificationTime, * Tilte = s.Title, * Description = s.Details, * //TypeOfCourses=d.CourseType.Deltail.ToList() * }); * var TotalCount = await a.CountAsync(); * var result = await a.Skip(input.PageNumber - 1).Take(input.PageSize).ToListAsync(); * return new PagedResultDto<GetAllCourseOutputDto>(TotalCount, result); * }*/ public async Task <long> CreateCourse(CreateCourseInput input) { using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete)) { if (IsTeacher() == true) { if (WorkScope.GetAll <Course>().Where(s => s.IsDeleted == false && (s.Title == input.Title || s.Code == input.Code)).Any()) { throw new UserFriendlyException("Đã tồn tại tên hoặc code khóa học"); } else { var a = input.MapTo <Course>(); a.UserId = AbpSession.UserId ?? 0; var id = await WorkScope.InsertAndGetIdAsync <Course>(a); return(id); } } else { throw new UserFriendlyException("Bạn không phải giáo viên, liên hệ admin để được hỗ trợ"); } } }
public CoursesDto CreateCourse(CreateCourseInput input) { var course = ObjectMapper.Map <Course>(input); var courseModel = _courseManager.CreateCourse(course); return(ObjectMapper.Map <CoursesDto>(courseModel)); }
public async Task CreateAsync(CreateCourseInput input) { var tenantId = 1; if (AbpSession.TenantId.HasValue) { tenantId = AbpSession.TenantId.Value; } var newCourse = Course.Create(tenantId, input.Title, input.Date, input.Description, input.MaxRegistrationCount); await _courseManager.CreateAsync(newCourse); }
public ActionResult AddCourse(CreateCourseInput input) { var list = _courseAppService.CreateCourse(input); return(Content(list.ToJson())); }