public async Task <LearningSessionDto> CreateLearningSessionAsync(LearningSessionDto dto)
        {
            var learningSession       = _learningSessionFactory.CreateLearningSession(dto.SessionName);
            var learningSessionFromDb = await _learningSessionRepository.SaveAsync(learningSession);

            var result = _mapper.Map <LearningSessionDto>(learningSessionFromDb);

            return(result);
        }
        public async Task <LearningSessionDto> UpdateLearningSessionAsync(LearningSessionDto dto)
        {
            Guard.StringNotNullOrEmpty(() => dto.Id);

            var learningSession = await _learningSessionRepository.LoadByIdAsync(dto.Id);

            _mapper.Map(dto, learningSession);

            var learningSessionFromDb = await _learningSessionRepository.SaveAsync(learningSession);

            var result = _mapper.Map <LearningSessionDto>(learningSessionFromDb);

            return(result);
        }
示例#3
0
        public async Task <ActionResult <LearningSessionDto> > SaveAsync([FromBody] LearningSessionDto dto)
        {
            var entity = _mapper.Map <LearningSession>(dto);

            entity.LearningSessionFacts = dto.FactIds.Select(id => new LearningSessionFact {
                FactId = id
            }).ToList();

            var returnedEntry = await _learningSessionRepo.SaveAsync(entity);

            var result = _mapper.Map <LearningSessionDto>(returnedEntry);

            return(Ok(result));
        }
示例#4
0
        public async Task <IActionResult> UpdateLearningSessionAsync([FromBody] LearningSessionDto dto)
        {
            var updatedLearningSession = await _learningSessionService.UpdateLearningSessionAsync(dto);

            return(Ok(updatedLearningSession));
        }
示例#5
0
        public async Task <IActionResult> CreateLearningSessionAsync([FromBody] LearningSessionDto dto)
        {
            var createdlearningSession = await _learningSessionService.CreateLearningSessionAsync(dto);

            return(Ok(createdlearningSession));
        }