public ActionResult addLot(Lot lot, int agent)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    Debug.WriteLine(lot);

                    LotService         LotService         = new LotService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);

                    LotService.Add(lot);
                    LotService.Commit();

                    Affectation affectation = new Affectation
                    {
                        DateAffectation = DateTime.Now,
                        LotId           = lot.LotId,
                        EmployeId       = agent
                    };

                    AffectationService.Add(affectation);
                    AffectationService.Commit();

                    return(RedirectToAction("ConsulterClients", new { numLot = 0, sortOrder = 0 }));
                }
            }
        }
        public ActionResult updateLot(ClientAffecteViewModel cavm)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    LotService         LotService         = new LotService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);

                    Lot newlot = LotService.GetById(cavm.Lot.LotId);
                    newlot.Adresse       = cavm.Lot.Adresse;
                    newlot.Compte        = cavm.Lot.Compte;
                    newlot.DescIndustry  = cavm.Lot.DescIndustry;
                    newlot.Emploi        = cavm.Lot.Emploi;
                    newlot.IDClient      = cavm.Lot.IDClient;
                    newlot.NomClient     = cavm.Lot.NomClient;
                    newlot.NumLot        = cavm.Lot.NumLot;
                    newlot.PostCode      = cavm.Lot.PostCode;
                    newlot.SoldeDebiteur = cavm.Lot.SoldeDebiteur;
                    newlot.TelFixe       = cavm.Lot.TelFixe;
                    newlot.TelPortable   = cavm.Lot.TelPortable;
                    newlot.Type          = cavm.Lot.Type;
                    newlot.Emploi        = cavm.Lot.Emploi;
                    LotService.Update(newlot);
                    LotService.Commit();


                    Affectation affectation = AffectationService.GetById(cavm.Affectation.AffectationId);
                    Debug.WriteLine(cavm.Affectation.EmployeId);

                    if (affectation == null)
                    {
                        Affectation aff = new Affectation
                        {
                            EmployeId       = cavm.Affectation.EmployeId,
                            LotId           = cavm.Lot.LotId,
                            DateAffectation = DateTime.Now
                        };

                        AffectationService.Add(aff);
                        AffectationService.Commit();
                    }
                    else
                    {
                        affectation.EmployeId       = cavm.Affectation.EmployeId;
                        affectation.LotId           = cavm.Lot.LotId;
                        affectation.DateAffectation = DateTime.Now;
                        AffectationService.Update(affectation);
                        AffectationService.Commit();
                    }


                    return(RedirectToAction("ConsulterClients", new { numLot = 0, sortOrder = 0 }));
                }
            }
        }