public void CreateVehicule(Vehicule Vehicule) { utOfWork.VehiculeRepository.Add(Vehicule); }
public void UpdateVehiculeDetached(Vehicule e) { utOfWork.VehiculeRepository.UpdateVehiculeDetached(e); }
public ActionResult EditVehicule(Vehicule vehi) { if (ModelState.IsValid) { //try //{ int idBat = db6.FindBatimentByParcAuto(vehi.Id_parc); var ac = BissInventaireEntities.Instance.Achat.Find(vehi.Id_achat); vehi.idBatiment = idBat; var bat = vs.findVehiculeByID(vehi.Id_Vehicule); vs.UpdateVehiculeDetached(vehi); vs.SaveVehicule(); return RedirectToAction("GetVehicule"); //} //catch (Exception ex) //{ // LogThread.WriteLine(ex.Message); // return RedirectToAction("Index", "Error"); //} } else { // ViewBag.msg = "Verifier l code postal"; ViewData["parc"] = new SelectList(BissInventaireEntities.Instance.Parc_auto.ToList(), "Id_parc", "Libelle"); ViewData["maintenance"] = new SelectList(BissInventaireEntities.Instance.Contrat.ToList(), "Id_contrat", "Num"); ViewData["achat"] = new SelectList(BissInventaireEntities.Instance.Achat.ToList(), "Id_achat", "Num_facture"); return View(); } }
public ActionResult CreateVehicule(Vehicule veh, FormCollection collection) { //int idfournisseur = db6.FindFournisseurByContrat((int)veh.Id_contrat); int idBat = db6.FindBatimentByParcAuto(veh.Id_parc); var ac = BissInventaireEntities.Instance.Achat.Find(veh.Id_achat); //veh.Prix_d_achat = (double)ac.Prix_d_achat; veh.idBatiment = idBat; if (ModelState.IsValid) { try { BissInventaireEntities.Instance.Vehicule.Add(veh); BissInventaireEntities.Instance.SaveChanges(); var Emp = (Utilisateur)Session["identifiant"]; Trace tr = new Trace(); tr.Dates = DateTime.Now; tr.Actions = "Ajouter une VĂ©hicule"; tr.Champs = veh.Matricule; tr.Tables = "Vehicule"; tr.Users = (Emp.Personnel.Matricule).ToString(); BissInventaireEntities.Instance.Trace.Add(tr); BissInventaireEntities.Instance.SaveChanges(); return RedirectToAction("GetVehicule"); } catch (Exception ex) { LogThread.WriteLine(ex.Message); return RedirectToAction("Index", "Error"); } } else { ViewData["parc"] = new SelectList(BissInventaireEntities.Instance.Parc_auto.ToList(), "Id_parc", "Libelle"); ViewData["maintenance"] = new SelectList(BissInventaireEntities.Instance.Contrat.ToList(), "Id_contrat", "Num"); ViewData["achat"] = new SelectList(BissInventaireEntities.Instance.Achat.ToList(), "Id_achat", "Num_facture"); return View(); } }