Example #1
0
        public async Task increaseCourseSizeAsync(int courseId)
        {
            var course = _courseRepository.GetById(ConvertToGuid.ToGuid(courseId));

            //SUM 1 THE PROP SIZE
            course.Result.MaxSize = course.Result.MaxSize + 1;
            var updateCommand = _mapper.Map <IncreaseCourseSizeCommand>(course);
            //UPDATE COURSE
            await _bus.SendCommand(updateCommand);
        }
        public async Task <IActionResult> GetById(int id)
        {
            var item = await _courseAppService.GetByIdAsync(ConvertToGuid.ToGuid(id));

            if (item == null)
            {
                return(NotFound());
            }

            return(Ok(item));
        }
Example #3
0
        public bool IsCourseFull(int id)
        {
            var courseIsFull = false;
            var course       = DbSet.AsNoTracking().FirstOrDefault(c => c.Id == ConvertToGuid.ToGuid(id));

            if (course.EnrolledStudents.Count >= course.MaxSize)
            {
                courseIsFull = true;
            }
            return(courseIsFull);
        }
Example #4
0
        public void increaseCourseSize(int courseId)
        {
            //GET THE COURSE BY ID
            var course = _courseRepository.GetById(ConvertToGuid.ToGuid(courseId));

            //SUM 1 THE PROP SIZE
            course.MaxSize = course.MaxSize + 1;
            var updateCommand = _mapper.Map <IncreaseCourseSizeCommand>(course);

            //UPDATE COURSE
            try
            {
                _bus.SendCommand(updateCommand);
            }
            catch (ExceptionIncreaseCourseSize ex)
            {
                throw new ExceptionIncreaseCourseSize(ex.Message);
            }
        }