public async Task <IActionResult> Edit(int id, [Bind("CategorieId,Nom,Description")] CategorieClient categorieClient) { if (id != categorieClient.CategorieId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(categorieClient); _context.Entry(categorieClient).Property(x => x.CreatedAt).IsModified = false; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategorieClientExists(categorieClient.CategorieId)) { return(NotFound()); } else { throw; } } catch (DbUpdateException) { ModelState.AddModelError("Nom", "Cette catégorie existe déjà"); return(View(categorieClient)); } return(RedirectToAction(nameof(Index))); } return(View(categorieClient)); }
public async Task <IActionResult> Edit(int id, [Bind("MissionId,Etat,Titre,Debut,Fin,Description,ClientId")] Mission mission) { if (id != mission.MissionId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(mission); _context.Entry(mission).Property(x => x.CreatedAt).IsModified = false; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MissionExists(mission.MissionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["listClients"] = new SelectList(_context.Clients, "ClientId", "Nom", mission.MissionId); return(View(mission)); }
public async Task <IActionResult> Edit(int id, [Bind("ClientId,Nom,Email,CategorieClientId")] Client client) { if (id != client.ClientId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(client); _context.Entry(client).Property(x => x.CreatedAt).IsModified = false; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientExists(client.ClientId)) { return(NotFound()); } else { throw; } } catch (DbUpdateException e) { if (e.InnerException.Message.Contains("Nom")) { ModelState.AddModelError("Nom", "Un client portant ce nom existe déjà"); } if (e.InnerException.Message.Contains("Email")) { ModelState.AddModelError("Email", "Cette adresse mail est déjà rattachée à un client"); } ViewData["listCats"] = new SelectList(_context.CategoriesClient, "CategorieId", "Nom", client.ClientId); return(View(client)); } return(RedirectToAction(nameof(Index))); } ViewData["listCats"] = new SelectList(_context.CategoriesClient, "CategorieId", "Nom", client.ClientId); return(View(client)); }
public async Task <IActionResult> Edit(int id, [Bind("DevisId,EtatDevis,Date,Montant,DevisDateFinale,MontantFinal,MissionId")] Devis devis) { if (id != devis.DevisId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(devis); _context.Entry(devis).Property(x => x.CreatedAt).IsModified = false; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DevisExists(devis.DevisId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } var listMissions = _context.Missions.Select(s => new { Text = s.MissionId + " (" + s.Titre + ")", Value = s.MissionId }).ToList(); ViewData["listMissions"] = new SelectList(listMissions, "Value", "Text", devis.DevisId); return(View(devis)); }