Beispiel #1
0
        public static ListOfSpeakersViewModel ToViewModel(this ListOfSpeakers source)
        {
            var model = new ListOfSpeakersViewModel()
            {
                AllSpeakers = source.AllSpeakers.Select(a => new ViewModels.ListOfSpeakers.SpeakerViewModel()
                {
                    Id          = a.Id,
                    Iso         = a.Iso,
                    Mode        = a.Mode,
                    Name        = a.Name,
                    OrdnerIndex = a.OrdnerIndex,
                }).ToObservableCollection(),
                ListClosed         = source.ListClosed,
                Name               = source.Name,
                ListOfSpeakersId   = source.ListOfSpeakersId,
                PausedQuestionTime = source.PausedSpeakerTime,
                PausedSpeakerTime  = source.PausedSpeakerTime,
                PublicId           = source.PublicId,
                QuestionsClosed    = source.QuestionsClosed,
                SpeakerTime        = source.SpeakerTime,
                QuestionTime       = source.QuestionTime,
                StartQuestionTime  = source.StartQuestionTime,
                StartSpeakerTime   = source.StartSpeakerTime,
                Status             = source.Status,
            };

            return(model);
        }
        public ListOfSpeakers CreateList(string id = null)
        {
            var databaseModel = new ListOfSpeakers();

            if (id != null)
            {
                databaseModel.ListOfSpeakersId = id;
            }
            dbContext.ListOfSpeakers.Add(databaseModel);
            dbContext.SaveChanges();
            return(databaseModel);
        }
Beispiel #3
0
        public async Task <ListOfSpeakersViewModel> CreateListAsync()
        {
            using var scope   = serviceScopeFactory.CreateScope();
            using var context = scope.ServiceProvider.GetRequiredService <MunityContext>();
            var databaseModel = new ListOfSpeakers();

            context.ListOfSpeakers.Add(databaseModel);
            await context.SaveChangesAsync();

            var viewModel = databaseModel.ToViewModel();

            lock (this.cachedLists)
            {
                this.cachedLists.Add(viewModel);
            }
            return(viewModel);
        }