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 })); } } }