public async Task <IActionResult> Create([Bind("Id,LanguageId,Info_Name")] InfoName infoName) { if (ModelState.IsValid) { _context.Add(infoName); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(infoName)); }
public async Task <IActionResult> Create([Bind(include: "InfoId,Pic,ImageMimeType")] Picture picture, IFormFile image, int infoId) { await using (var fs1 = image.OpenReadStream()) { await using var ms1 = new MemoryStream(); fs1.CopyTo(ms1); picture.Pic = ms1.ToArray(); } picture.ImageMimeType = image.ContentType; picture.InfoId = infoId; if (ModelState.IsValid) { _context.Picture.Add(picture); await _context.SaveChangesAsync().ConfigureAwait(true); return(RedirectToAction(nameof(Index))); } return(View(picture)); }
public async Task <IActionResult> CreateP([Bind("Id,InfoId,Textblock1")] TextBlock textBlock) { if (ModelState.IsValid) { _context.Add(textBlock); await _context.SaveChangesAsync(); 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(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() })); }