public void DeleteUnit(int unitId) { var tickets = TicketRepository.GetAll().Where(x => x.FunctionalUnit.Id == unitId).ToList(); foreach (var ticket in tickets) { TicketRepository.Delete(ticket); } var renters = RenterRepository.GetAll().Where(x => x.FunctionalUnitId.HasValue && x.FunctionalUnitId.Value == unitId).ToList(); foreach (var renter in renters) { renter.FunctionalUnitId = null; RenterRepository.Update(renter); } var owners = OwnerRepository.GetAll().Where(x => x.FunctionalUnitId.HasValue && x.FunctionalUnitId.Value == unitId).ToList(); foreach (var owner in owners) { owner.FunctionalUnitId = null; OwnerRepository.Update(owner); } var unit = UnitRepository.GetById(unitId); UnitRepository.Delete(unit); }
public ActionResult Index() { if (Session["Id"] != null) { return(View(repo.GetAll())); } else { return(RedirectToAction("Login", "Login")); } }
public List <Renter> GetAll() { var users = RenterRepository.GetAll(); if (users == null) { throw new BadRequestException(ErrorMessages.UserNoEncontrado); } var result = new List <Renter>(); var enumerator = users.GetEnumerator(); while (enumerator.MoveNext()) { result.Add(enumerator.Current); } return(result); }
public List <Renter> GetAll() { return(RenterRepository.GetAll().ToList()); }