public ActionResult EditVoyage(Entity.Voyage value) { ViewBag.Title = "Edit Voyage"; ViewBag.postInfo = "L'enregistrement voyage saved successfuly"; ViewBag.postInfoClass = "alert-success"; var vehiculeTypes = new SelectList(new List <Object> { new { Id = "BUS", Name = "Bus" }, new { Id = "TRAIN", Name = "Train" }, new { Id = "AVION", Name = "Avion" }, new { Id = "TAXI", Name = "Taxi" }, }, "Id", "Name"); ViewBag.vehiculeTypes = vehiculeTypes; Console.WriteLine(value.Id + ";" + value.DepartId + ";" + value.ArrivalId + ";" + value.DepartTime + ";" + value.ArrivalTime + ";" + value.CompanyId); using (var dao = new Dao.Dao()) { var listCompanies = dao.CompaniesList(); ViewBag.listVilles = new SelectList(dao.VillesList(), "Id", "Name"); ViewBag.listCompanies = new SelectList(listCompanies, "Id", "Name"); var listVehicules = listCompanies.Count > 0 ? dao.VehiculesListFor(listCompanies[0].Id) : new List <Vehicule>(); ViewBag.listVehicules = new SelectList(listVehicules, "Id", "Name"); if (!ModelState.IsValid) { Console.WriteLine("Error, model non valid"); ViewBag.Error = "Model non valid"; return(View(value)); } if (value.ArrivalTime < value.DepartTime) { ModelState.AddModelError("DeparTime", "La date d'arrivé ne peut être superieur à la date de depart"); return(View(value)); } dao.UpdateVoyage(value); return(View("Saved")); } }
public Entity.Voyage InsertVoyage(Entity.Voyage v) { v = Context.Voyages.Add(v); Context.SaveChanges(); return(v); }
public Entity.Voyage UpdateVoyage(Entity.Voyage c) { Context.Voyages.AddOrUpdate(c); Context.SaveChanges(); return(c); }