コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Prefix,Firstname,Lastname,Description,Influentialpeople,Language")] InfluentialPeopleTrans influentialPeopleTrans)
        {
            if (id != influentialPeopleTrans.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(influentialPeopleTrans);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InfluentialPeopleTransExists(influentialPeopleTrans.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["Influentialpeople"] = new SelectList(_context.InfluentialPeople, "Id", "Id", influentialPeopleTrans.Influentialpeople);
            ViewData["Language"]          = new SelectList(_context.Languages, "Id", "Code", influentialPeopleTrans.Language);
            return(View(influentialPeopleTrans));
        }
コード例 #2
0
        public async Task <IActionResult> Create(int InfluentialPeople, [Bind("Id,Prefix,Firstname,Lastname,Description,Influentialpeople,Language")] InfluentialPeopleTrans influentialPeopleTrans)
        {
            if (ModelState.IsValid)
            {
                if (InfluentialPeople == 0)
                {
                    InfluentialPeople entry = new InfluentialPeople(); _context.Add(entry); influentialPeopleTrans.Influentialpeople = entry.Id;
                }

                _context.Add(influentialPeopleTrans);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["Influentialpeople"] = new SelectList(_context.InfluentialPeople, "Id", "Id", influentialPeopleTrans.Influentialpeople);
            ViewData["Language"]          = new SelectList(_context.Languages, "Id", "Code", influentialPeopleTrans.Language);
            return(View(influentialPeopleTrans));
        }