/// <summary> /// Creates new Ls (learning scenario) and its corresponding /// objects such as keywords, teachingcorrelationsubjects and learningoutcomes. /// </summary> /// <param name="model"></param> /// <returns>Id of newly created scenario</returns> public async Task <int> CreateScenario(LsBM model) { var ls = mapper.Map <Ls>(model); ls.UserId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; ls.LearningOutcomeCtid = await learningOutcomeCtRepository.CreateLearningOutcomeCts(model.LearningOutcomeCts); ls.LearningOutcomeSubjectId = await learningOutcomeSubjectRepository.CreateLearningOutcomeSubject(model.LearningOutcomeSubjects); ls.Lsduration = TimeSpan.Zero; context.Ls.Add(ls); await context.SaveChangesAsync(); await keywordRepository.CreateKeywords(model.Keywords, ls.Idls); await lsCorrelationRepository.CreateTeachingCorrelationSubjects(model.CorrelationSubjectIds, ls.Idls); logger.LogInformation($"Successfully created learning scenario with id { ls.Idls }"); return(ls.Idls); }