Ejemplo n.º 1
0
        /* 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ợ");
                }
            }
        }
Ejemplo n.º 2
0
        public CoursesDto CreateCourse(CreateCourseInput input)
        {
            var course      = ObjectMapper.Map <Course>(input);
            var courseModel = _courseManager.CreateCourse(course);

            return(ObjectMapper.Map <CoursesDto>(courseModel));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public ActionResult AddCourse(CreateCourseInput input)
        {
            var list = _courseAppService.CreateCourse(input);

            return(Content(list.ToJson()));
        }