Example #1
0
        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);
        }
Example #2
0
 public ActionResult Index()
 {
     if (Session["Id"] != null)
     {
         return(View(repo.GetAll()));
     }
     else
     {
         return(RedirectToAction("Login", "Login"));
     }
 }
Example #3
0
        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);
        }
Example #4
0
 public List <Renter> GetAll()
 {
     return(RenterRepository.GetAll().ToList());
 }