Imports System Imports System.Collections.Generic Imports System.Data Imports System.Data.Entity Imports System.Linq Imports System.Net Imports System.Web Imports System.Web.Mvc Imports WebApplication16 Namespace Controllers Public Class SinistresController Inherits System.Web.Mvc.Controller Private db As New databaseEntities ' GET: Sinistres ' Function Index() As ActionResult 'Dim sinistre = db.Sinistre.Include(Function(s) s.Compagnie).Include(Function(s) s.Expert).Include(Function(s) s.Nature).Include(Function(s) s.Vehicules) 'Return View(sinistre.ToList()) ' End Function Function V_sinistreclos() As ActionResult Return View(db.V_Sinistreclos.ToList()) End Function Function V_sinistre() As ActionResult Return View(db.V_Sinistre.ToList()) End Function Function Index(ByVal fc As FormCollection, ByVal id As String) Return "

From <HttpPost>Index: " & id & "

" End Function Function index(ByVal id As String) As ActionResult ' Dim searchstring = id.ToString 'If IsNothing(id) Then 'Return View(db.Sinistre.ToList()) 'New HttpStatusCodeResult(HttpStatusCode.BadRequest) 'End If ' Dim sinistre As Sinistre = db.Sinistre.Find(id) ' If IsNothing(sinistre) Then ' Return HttpNotFound() ' End If ' Return View(sinistre) Dim searchString = id Dim query = From m In db.Sinistre Select m If Not String.IsNullOrEmpty(searchString) Then query = query.Where(Function(movie) movie.IDSINISTRE.Equals(searchString)) End If Return View(query) End Function ' GET: Sinistres/Details/5 Function Details(ByVal id As Integer?) As ActionResult If IsNothing(id) Then Return New HttpStatusCodeResult(HttpStatusCode.BadRequest) End If Dim sinistre As Sinistre = db.Sinistre.Find(id) If IsNothing(sinistre) Then Return HttpNotFound() End If Return View(sinistre) End Function ' GET: Sinistres/Create Function Create() As ActionResult ViewBag.IDCOMPAGNIE = New SelectList(db.Compagnie, "IDCOMPAGNIE", "Compagnie1") ViewBag.IDEXPERT = New SelectList(db.Expert, "IDEXPERT", "Nom_") ViewBag.IDNATURE = New SelectList(db.Nature, "IDNATURE", "NATURE1") ViewBag.IDVEHICULE = New SelectList(db.Vehicules, "IDVEHICULE", "Matricule") Return View() End Function ' POST: Sinistres/Create 'Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour 'plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598. Function Create( ByVal sinistre As Sinistre) As ActionResult If ModelState.IsValid Then db.Sinistre.Add(sinistre) db.SaveChanges() Return RedirectToAction("Index") End If ViewBag.IDCOMPAGNIE = New SelectList(db.Compagnie, "IDCOMPAGNIE", "Compagnie1", sinistre.IDCOMPAGNIE) ViewBag.IDEXPERT = New SelectList(db.Expert, "IDEXPERT", "Nom_", sinistre.IDEXPERT) ViewBag.IDNATURE = New SelectList(db.Nature, "IDNATURE", "NATURE1", sinistre.IDNATURE) ViewBag.IDVEHICULE = New SelectList(db.Vehicules, "IDVEHICULE", "Matricule", sinistre.IDVEHICULE) Return View(sinistre) End Function ' GET: Sinistres/Edit/5 Function Edit(ByVal id As Integer?) As ActionResult If IsNothing(id) Then Return New HttpStatusCodeResult(HttpStatusCode.BadRequest) End If Dim sinistre As Sinistre = db.Sinistre.Find(id) If IsNothing(sinistre) Then Return HttpNotFound() End If ViewBag.IDCOMPAGNIE = New SelectList(db.Compagnie, "IDCOMPAGNIE", "Compagnie1", sinistre.IDCOMPAGNIE) ViewBag.IDEXPERT = New SelectList(db.Expert, "IDEXPERT", "Nom_", sinistre.IDEXPERT) ViewBag.IDNATURE = New SelectList(db.Nature, "IDNATURE", "NATURE1", sinistre.IDNATURE) ViewBag.IDVEHICULE = New SelectList(db.Vehicules, "IDVEHICULE", "Matricule", sinistre.IDVEHICULE) Return View(sinistre) End Function ' POST: Sinistres/Edit/5 'Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour 'plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598. Function Edit( ByVal sinistre As Sinistre) As ActionResult If ModelState.IsValid Then db.Entry(sinistre).State = EntityState.Modified db.SaveChanges() Return RedirectToAction("Index") End If ViewBag.IDCOMPAGNIE = New SelectList(db.Compagnie, "IDCOMPAGNIE", "Compagnie1", sinistre.IDCOMPAGNIE) ViewBag.IDEXPERT = New SelectList(db.Expert, "IDEXPERT", "Nom_", sinistre.IDEXPERT) ViewBag.IDNATURE = New SelectList(db.Nature, "IDNATURE", "NATURE1", sinistre.IDNATURE) ViewBag.IDVEHICULE = New SelectList(db.Vehicules, "IDVEHICULE", "Matricule", sinistre.IDVEHICULE) Return View(sinistre) End Function ' GET: Sinistres/Delete/5 Function Delete(ByVal id As Integer?) As ActionResult If IsNothing(id) Then Return New HttpStatusCodeResult(HttpStatusCode.BadRequest) End If Dim sinistre As Sinistre = db.Sinistre.Find(id) If IsNothing(sinistre) Then Return HttpNotFound() End If Return View(sinistre) End Function ' POST: Sinistres/Delete/5 Function DeleteConfirmed(ByVal id As Integer) As ActionResult Dim sinistre As Sinistre = db.Sinistre.Find(id) db.Sinistre.Remove(sinistre) db.SaveChanges() Return RedirectToAction("Index") End Function Protected Overrides Sub Dispose(ByVal disposing As Boolean) If (disposing) Then db.Dispose() End If MyBase.Dispose(disposing) End Sub End Class End Namespace