public void CreateMouvementBien(MouvementBien MouvementBien)
        {

            utOfWork.MouvementBienRepository.Add(MouvementBien);


        }
        public ActionResult EditMouvementBien(MouvementBien mou)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db8.UpdateMouvementBienDetached(mou);
                    db8.SaveMouvementBien();
                    return RedirectToAction("GetMouvementBien");
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return RedirectToAction("Index", "Error");
                }
            }
            else

            {
                ViewData["bien"] = new SelectList(BissInventaireEntities.Instance.Bien.ToList(), "Id_bien", "Code_a_barre");
                ViewData["batiment"] = new SelectList(BissInventaireEntities.Instance.Batiment.ToList(), "idBatiment", "description");
                ViewData["etage"] = new SelectList(BissInventaireEntities.Instance.Etage.ToList(), "Id_etage", "description");
                ViewData["delegation"] = new SelectList(BissInventaireEntities.Instance.Delegation.ToList(), "idDelegation", "libelle");
                return View();
            }
        }
        public ActionResult CreateMouvementBien(MouvementBien mou, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db8.CreateMouvementBien(mou);
                    db8.SaveMouvementBien();
                    var Emp = (Utilisateur)Session["identifiant"];
                    Trace tr = new Trace();
                    tr.Dates = DateTime.Now;
                    tr.Actions = "Ajout Mouvement Bien";
                    //tr.Champs = (mou.Bien.Code_a_barre).ToString();
                    tr.Tables = "Mouvement Bien";
                    tr.Users = (Emp.Personnel.Matricule).ToString();
                    BissInventaireEntities.Instance.Trace.Add(tr);
                    BissInventaireEntities.Instance.SaveChanges();
                    return RedirectToAction("GetMouvementBien");
                }
                catch (DbEntityValidationException r)
                {


                    foreach (var eve in r.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                            eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        LogThread.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors: " +
                            eve.Entry.Entity.GetType().Name + " " + eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                ve.PropertyName, ve.ErrorMessage);
                            LogThread.WriteLine("- Property: \"{0}\", Error: \"{1}\" " +
                                ve.PropertyName + " " + ve.ErrorMessage);
                            ViewBag.msg2 = "Exeption:  " + ve.ErrorMessage;


                        }
                    }

                    return RedirectToAction("Index", "Error");
                }
                catch (SqlException sq)
                {
                    LogThread.WriteLine(sq.Message);
                    return RedirectToAction("Index", "Error");
                }
                catch (Exception ex)
                {
                    LogThread.WriteLine(ex.Message);
                    return RedirectToAction("Index", "Error");
                }
            }
            else

            {
                ViewData["batiment"] = new SelectList(BissInventaireEntities.Instance.Batiment.ToList(), "idBatiment", "description");
                ViewData["etage"] = new SelectList(BissInventaireEntities.Instance.Etage.ToList(), "Id_etage", "description");
                ViewData["delegation"] = new SelectList(BissInventaireEntities.Instance.Delegation.ToList(), "idDelegation", "libelle");
                //ViewData["bien"] = new SelectList(BissInventaireEntities.Instance.Bien.ToList(), "Id_bien", "Num_serie");
                ViewData["bien"] = new SelectList(BissInventaireEntities.Instance.Bien.ToList(), "Id_bien", "Code_a_barre");
                return View();
            }
        }
 public void UpdateMouvementBienDetached(MouvementBien e)
 {
     utOfWork.MouvementBienRepository.UpdateMouvementBienDetached(e);
 }