コード例 #1
0
ファイル: TagController.cs プロジェクト: tunglin0315/cciscore
        public async Task <IActionResult> Edit(int id, [Bind("Id,TagName")] Tag tag)
        {
            if (id != tag.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tag);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TagExists(tag.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tag));
        }
コード例 #2
0
        //public async Task<IActionResult> Edit(int id, [Bind("Id,CostYear,PlanName,NumberLaw,DefiProjectCalss,ExecutiveUnit,PlanHost,ProjectClass,KeywordTw,SummaryTw,KeywordEng,SummaryEng")] Knowledged knowledge)
        public async Task <IActionResult> Edit(int id, KnowledgeViewModel vm_knowledge)
        {
            if (id != vm_knowledge.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Knowledged knowledgeds = new Knowledged
                    {
                        Id               = vm_knowledge.Id,
                        CostYear         = vm_knowledge.CostYear,
                        PlanName         = vm_knowledge.PlanName,
                        NumberLaw        = vm_knowledge.NumberLaw,
                        DefiProjectClass = vm_knowledge.DefiProjectClass,
                        ExecutiveUnit    = vm_knowledge.ExecutiveUnit,
                        PlanHost         = vm_knowledge.PlanHost,
                        ProjectClass     = vm_knowledge.ProjectClass,
                        KeywordTw        = vm_knowledge.KeywordTw,
                        SummaryTw        = vm_knowledge.SummaryTw,
                        KeywordEng       = vm_knowledge.KeywordEng,
                        InfoLink         = vm_knowledge.InfoLink
                    };
                    _context.Update(knowledgeds);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KnowledgeExists(vm_knowledge.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vm_knowledge));
        }