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 })); } } }
public ActionResult deleteLot(int id, string currentFilter, string currentNumLot, string currentPage) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); LotService.Delete(LotService.GetById(id)); LotService.Commit(); return(RedirectToAction("ConsulterClients", "Lot", new { currentFilter, currentNumLot, currentPage })); } } }
public ActionResult updateLot(int id) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); AffectationService AffectationService = new AffectationService(UOW); EmployeService EmpService = new EmployeService(UOW); ViewData["list"] = new SelectList(NumLotListForDropDown(), "Value", "Text"); ViewData["agent"] = new SelectList(AgentListForDropDown(), "Value", "Text"); //Lot lot = LotService.GetById(id); ClientAffecteViewModel cavm = new ClientAffecteViewModel(); cavm = (from a in AffectationService.GetAll() join l in LotService.GetAll() on a.LotId equals l.LotId where l.LotId == id select new ClientAffecteViewModel { Affectation = a, Lot = l }).FirstOrDefault(); if (cavm == null) { cavm = new ClientAffecteViewModel(); Lot lot = LotService.GetById(id); cavm.Lot = lot; } return(View(cavm)); } } }