public async Task <IActionResult> Create([Bind("Id,nom,prenom,dateNaissance,sexe,role")] Personne personne) { if (ModelState.IsValid) { _context.Add(personne); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(personne)); }
public async Task <IActionResult> Create([Bind("Id,Marque,NumLot,DateInjection,DateRappel,TypeVaccin")] Injections injections) { if (ModelState.IsValid) { _context.Add(injections); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(injections)); }
public async Task <IActionResult> Create([Bind("Id,Nom,Prenom,Sexe,DateNaissance,TypePersonne")] Personnes personnes) { if (ModelState.IsValid) { _context.Add(personnes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(personnes)); }
public async Task <IActionResult> Create([Bind("Id,Libelle,Description")] Categorie categorie) { if (ModelState.IsValid) { _context.Add(categorie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(categorie)); }
public async Task <IActionResult> Create([Bind("Id,dateInjection,dateRappel,numLot,marque")] Injection injection) { if (ModelState.IsValid) { _context.Add(injection); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(injection)); }
public async Task <IActionResult> Create([Bind("Id,Nom")] Vaccin vaccin) { if (ModelState.IsValid) { _context.Add(vaccin); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(vaccin)); }
public async Task <IActionResult> Create([Bind("InjectionsId,PersonnesId")] InjectionsPersonnes injectionsPersonnes) { if (ModelState.IsValid) { _context.Add(injectionsPersonnes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["InjectionsId"] = new SelectList(_context.Injections, "Id", "Id", injectionsPersonnes.InjectionsId); ViewData["PersonnesId"] = new SelectList(_context.Personnes, "Id", "Id", injectionsPersonnes.PersonnesId); return(View(injectionsPersonnes)); }
public async Task <IActionResult> Edit(int id, [Bind("VetementId,Nom")] Vetement vetement) { if (id != vetement.VetementId) { return(NotFound()); } // Fetch Contact from DB to get OwnerID. var v = await Contexte .Vetement.AsNoTracking() .FirstOrDefaultAsync(m => m.VetementId == id); if (v == null) { return(NotFound()); } var isAuthorized = await AuthorizationService.AuthorizeAsync( User, v, VetementOperations.Update); if (!isAuthorized.Succeeded) { return(Forbid()); } vetement.ProprietaireId = v.ProprietaireId; try { Contexte.Vetement.Update(vetement); await Contexte.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VetementExists(vetement.VetementId)) { return(NotFound()); } else { throw; } } if (ModelState.IsValid) { return(RedirectToAction(nameof(Index))); } return(View(vetement)); }
public async Task <IActionResult> DeleteConfirmed(int id) { var vetement = await Contexte.Vetement.FindAsync(id); if (vetement == null) { return(NotFound()); } var isAuthorized = await AuthorizationService.AuthorizeAsync( User, vetement, VetementOperations.Delete); if (!isAuthorized.Succeeded) { return(Forbid()); } Contexte.Vetement.Remove(vetement); await Contexte.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("VetementId,Nom")] Vetement vetement) { if (ModelState.IsValid) { vetement.ProprietaireId = UserManager.GetUserId(User); // requires using ContactManager.Authorization; var isAuthorized = await AuthorizationService.AuthorizeAsync( User, vetement, VetementOperations.Create); if (!isAuthorized.Succeeded) { return(Forbid()); } Contexte.Add(vetement); await Contexte.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(vetement)); }