public async Task <IActionResult> Edit(int id, [Bind("Id,NomFichier,IdDestination")] Photo photo) { if (id != photo.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(photo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhotoExists(photo.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdDestination"] = new SelectList(_context.Destination, "Id", "Nom", photo.IdDestination); return(View(photo)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,NumeroCb,PrixTotal,IdClient,IdEtatDossier,IdVoyage")] Dossierresa dossierresa) { if (id != dossierresa.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dossierresa); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DossierresaExists(dossierresa.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdClient"] = new SelectList(_context.Client, "Id", "Id", dossierresa.IdClient); ViewData["IdEtatDossier"] = new SelectList(_context.Etatdossier, "Id", "Libelle", dossierresa.IdEtatDossier); ViewData["IdVoyage"] = new SelectList(_context.Voyage, "Id", "Descriptif", dossierresa.IdVoyage); return(View(dossierresa)); }
public async Task <IActionResult> Edit(int id, byte IdEtatDossier) { var dossier = await _context.Dossierresa.Include(d => d.IdVoyageNavigation).ThenInclude(v => v.Voyageur).SingleOrDefaultAsync(d => d.Id == id); if (IdEtatDossier == 3) { var voyage = dossier.IdVoyageNavigation; voyage.PlacesDispo += voyage.Voyageur.Count(); _context.Voyage.Update(voyage); } else if (IdEtatDossier != 3 && dossier.IdEtatDossier == 3) { var voyage = dossier.IdVoyageNavigation; voyage.PlacesDispo -= voyage.Voyageur.Count(); _context.Voyage.Update(voyage); } dossier.IdEtatDossier = IdEtatDossier; _context.Update(dossier); await _context.SaveChangesAsync(); ViewData["IdEtatDossier"] = new SelectList(_context.Etatdossier, "Id", "Libelle", dossier.IdEtatDossier); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, [Bind("Id,IdParente,Nom,Niveau,Description")] Destination destination) { if (id != destination.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(destination); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DestinationExists(destination.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdParente"] = new SelectList(_context.Destination, "Id", "Nom", destination.IdParente); return(View(destination)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,TypePers,Civilite,Nom,Prenom,Email,Telephone,Datenaissance")] Personne personne) { if (id != personne.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(personne); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonneExists(personne.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(personne)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,IdDestination,DateDepart,DateRetour,PlacesDispo,PrixHt,Reduction,Descriptif")] Voyage voyage) { if (id != voyage.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(voyage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VoyageExists(voyage.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdDestination"] = new SelectList(_context.Destination, "Id", "Nom", voyage.IdDestination); return(View(voyage)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,NumeroCb,PrixTotal,IdClient,IdEtatDossier,IdVoyage")] Dossierresa dossierresa) { if (id != dossierresa.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dossierresa); if (dossierresa.IdEtatDossier == 2)//dossier Validé { var voyage = await _context.Voyage.Include(v => v.Voyageur).Where(v => v.Id == dossierresa.IdVoyage).FirstOrDefaultAsync(); voyage.PlacesDispo -= 1 + voyage.Voyageur.Count(); _context.Update(voyage); } await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DossierresaExists(dossierresa.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdClient"] = new SelectList(_context.Client, "Id", "Id", dossierresa.IdClient); ViewData["IdEtatDossier"] = new SelectList(_context.Etatdossier, "Id", "Libelle", dossierresa.IdEtatDossier); ViewData["IdVoyage"] = new SelectList(_context.Voyage, "Id", "Descriptif", dossierresa.IdVoyage); return(View(dossierresa)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,IdParente,Nom,Niveau,Description")] Destination destination, List <IFormFile> photos) { if (id != destination.Id) { return(NotFound()); } if (ModelState.IsValid) { try { foreach (var photo in photos) { if (photo.Length > 0 && (photo.FileName.EndsWith(".png")) || (photo.FileName.EndsWith(".jpeg")) || (photo.FileName.EndsWith(".jpg"))) { var myUniqueFileName = Convert.ToString(Guid.NewGuid()); var FileExtension = Path.GetExtension(photo.FileName); using (var stream = System.IO.File.Create(ROOT + myUniqueFileName + FileExtension)) { await photo.CopyToAsync(stream); } var photoSql = new Photo() { IdDestination = destination.Id, NomFichier = myUniqueFileName + FileExtension }; destination.Photo.Add(photoSql); } } _context.Update(destination); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DestinationExists(destination.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdParente"] = new SelectList(_context.Destination, "Id", "Nom", destination.IdParente); return(View(destination)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,TypePers,Civilite,Nom,Prenom,Email,Telephone,Datenaissance")] Personne personne) { if (id != personne.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(personne); await _context.SaveChangesAsync(); var user = await _contextApp.Users.Where(u => u.Email == User.FindFirstValue(ClaimTypes.Name)).SingleOrDefaultAsync(); user.Email = personne.Email; user.UserName = personne.Email; user.PhoneNumber = personne.Telephone; await _userManager.UpdateAsync(user); await _signInManager.SignInAsync(user, true); } catch (DbUpdateConcurrencyException) { if (!PersonneExists(personne.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Details")); } return(View(personne)); }