コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,LanguageId,Info_Name")] InfoName infoName)
        {
            if (id != infoName.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(infoName);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InfoNameExists(infoName.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(infoName));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,InfoId,Pic,ImageMimeType")] Picture picture)
        {
            if (id != picture.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(picture);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PictureExists(picture.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InfoId"] = new SelectList(_context.InfoName, "Id", "Id", picture.InfoId);
            return(View(picture));
        }
コード例 #3
0
        public async Task <IActionResult> EditP(int id, [Bind("Id,InfoId,Textblock1")] TextBlock textBlock)
        {
            if (id != textBlock.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(textBlock);
                    await _context.SaveChangesAsync().ConfigureAwait(true);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TextBlockExists(textBlock.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(PartialView("_IndexName", new InfoViewModel()
                {
                    InfoNameVM = _context.InfoName.Where(s => s.Id == textBlock.InfoId).ToList(),
                    TextBlockVM = _context.TextBlock.Where(s => s.InfoId == textBlock.InfoId).ToList(),
                    PictureVM = _context.Picture.Where(s => s.InfoId == textBlock.InfoId).ToList()
                }));
            }
            ViewData["InfoId"] = new SelectList(_context.InfoName, "Id", "Id", textBlock.InfoId);
            return(View("Error"));
        }