public async Task <IActionResult> Create([Bind("Nom,Description")] Aliment aliment) { if (ModelState.IsValid) { _context.Add(aliment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(aliment)); }
public async Task <IActionResult> Create([Bind("Nom,PaysId")] Region region) { if (ModelState.IsValid) { _context.Add(region); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.Pays = new SelectList(await _context.Pays.ToListAsync(), "Id", "Nom", region.PaysId); return(View(region)); }
public async Task <IActionResult> Create([Bind("LocalizableEntityId,PrimaryKeyValue,FieldName,LanguageId,Text")] LocalizableEntityTranslation localizableEntityTranslation) { if (ModelState.IsValid) { _context.Add(localizableEntityTranslation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.Languages = new SelectList(await _context.Languages.ToListAsync(), "Id", "Name", localizableEntityTranslation.LanguageId); ViewBag.Entitys = new SelectList(await _context.LocalizableEntitys.ToListAsync(), "Id", "EntityName", localizableEntityTranslation.LocalizableEntityId); return(View(localizableEntityTranslation)); }
public async Task <IActionResult> Create([Bind("Id,Code,Name")] Language language) { if (ModelState.IsValid) { _context.Add(language); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(language)); }
public async Task <IActionResult> Create([Bind("Nom")] Couleur couleur) { if (ModelState.IsValid) { _context.Add(couleur); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(couleur)); }
public async Task <IActionResult> Create([Bind("Id,EntityName,PrimaryKeyFieldName")] LocalizableEntity localizableEntity) { if (ModelState.IsValid) { _context.Add(localizableEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.Entitys = _entitys; return(View(localizableEntity)); }
public async Task <IActionResult> Create([Bind("Nom,Description,Type,Millesime,Volume,Image,CouleurId,PaysId,RegionId,CaveId,Quantite")] Vin vin, int[] AlimentsId) { if (ModelState.IsValid) { _context.Add(vin); foreach (int aliment in AlimentsId) { _context.Add(new VinAliment { VinId = vin.Id, AlimentId = aliment }); } await _context.SaveChangesAsync(); return(RedirectToAction("Details", "Caves")); } ViewBag.CaveId = vin.CaveId; ViewBag.Couleurs = _localization.ApplyTranslateSelectList(await _context.Couleurs.ToListAsync(), "Id", "Nom", vin.CouleurId); ViewBag.Pays = _localization.ApplyTranslateSelectList(await _context.Pays.ToListAsync(), "Id", "Nom", vin.PaysId); ViewBag.Regions = new SelectList(await _context.Regions.ToListAsync(), "Id", "Nom", vin.RegionId); ViewBag.Aliments = _localization.ApplyTranslateSelectList(await _context.Aliments.ToListAsync(), "Id", "Nom"); return(View(vin)); }
public async Task <IActionResult> Create([Bind("Nom,Description,UtilisateurId")] Cave cave) { //USER if (ModelState.IsValid) { _context.Add(cave); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.Utilisateurs = new SelectList(await _context.Utilisateurs.ToListAsync(), "Id", "UserName", cave.UtilisateurId); return(View(cave)); }
public async Task <IActionResult> Create([Bind("Id,Nom,Description")] Cave cave) { if (ModelState.IsValid) { var user = await _userManager.GetUserAsync(User); cave.Utilisateur = user; _context.Add(cave); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details))); } return(View(cave)); }