예제 #1
0
        public async Task <IActionResult> AddQuestionType(CompanyQuestionTypeViewModel model)
        {
            if (ModelState.IsValid)
            {
                var questionType = await _dataContext.QuestionTypes.FindAsync(model.QuestionTypeId);

                var company = await _dataContext.Companies.FindAsync(model.CompanyId);

                var qst = new CompanyQuestionType
                {
                    Company      = company,
                    QuestionType = questionType,
                };
                _dataContext.CompanyQuestionTypes.Add(qst);
                await _dataContext.SaveChangesAsync();

                return(RedirectToAction($"{nameof(Details)}/{model.CompanyId}"));
            }

            return(View(model));
        }
예제 #2
0
        public async Task <IActionResult> AddQuestionType(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var company = await _dataContext.Companies.FindAsync(id.Value);

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

            var model = new CompanyQuestionTypeViewModel
            {
                CompanyId     = company.Id,
                QuestionTypes = _combosHelper.GetComboQuestionsTypes(),
            };

            return(View(model));
        }