public async Task <IActionResult> Create([Bind("KeywordDefinitionId,KeywordDefinitionName,ApplicationId,ApplicationName,Field1Description,Field2Description,Field3Description,Field4Description,Field5Description,Field6Description,Field7Description,Field8Description,Field9Description,Field10Description,Field11Description,Field12Description,Field13Description,Field14Description,Field15Description,Field16Description,Field17Description,Field18Description,Field19Description,Field20Description,Field21Description,Field22Description,Field23Description,Field24Description,Field25Description")] KeywordDefinition keywordDefinition)
        {
            if (ModelState.IsValid)
            {
                _context.Add(keywordDefinition);
                await _context.SaveChangesAsync();

                var thisApp = _dataDictionaryRepository.GetApplicationById(keywordDefinition.ApplicationId);
                if (thisApp != null)
                {
                    keywordDefinition.ApplicationName = thisApp.ApplicationName;
                    _context.SaveChanges();
                }

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApplicationId"] = new SelectList(_context.Applications, "ApplicationId", "ApplicationName", keywordDefinition.ApplicationId);
            return(View(keywordDefinition));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("KeywordId,KeywordDefinitionId,KeywordDefinitionName,Field1,Field2,Field3,Field4,Field5,Field6,Field7,Field8,Field9,Field10,Field11,Field12,Field13,Field14,Field15,Field16,Field17,Field18,Field19,Field20,Field21,Field22,Field23,Field24,Field25")] Keyword keyword)
        {
            if (ModelState.IsValid)
            {
                _context.Add(keyword);
                await _context.SaveChangesAsync();

                var thisDef = _dataDictionaryRepository.GetDefinitionById(keyword.KeywordDefinitionId);
                if (thisDef != null)
                {
                    keyword.KeywordDefinitionName = thisDef.KeywordDefinitionName;
                    _context.SaveChanges();
                }

                //Dispaly the Keyword Definition only for selection, hit Save and then display the whole model for editing
                return(RedirectToAction("Edit", "Keywords", new { id = keyword.KeywordId }));
            }
            ViewData["KeywordDefinitionId"] = new SelectList(_context.KeywordDefinitions, "KeywordDefinitionId", "KeywordDefinitionName", keyword.KeywordDefinitionId);
            return(View(keyword));
        }