public List <Lodging> GetAllLoadings() { try { List <Lodging> allLodgings = lodgingRepository.GetAll().ToList(); return(allLodgings); } catch (ClientException e) { throw new ClientBusinessLogicException(MessageExceptionBusinessLogic.ErrorNotExistLodgigns, e); } catch (ServerException e) { throw new ServerBusinessLogicException(MessageExceptionBusinessLogic.ErrorObteinedAllLodgings, e); } }
/// <summary> /// Returns all available lodging locations on basis of Animal. /// Automatically check if one more animal would fit; and other business rules. /// </summary> /// <param name="ID">ID of the animal.</param> /// <returns>Available Lodges.</returns> public IEnumerable <Lodging> ReturnAvailableLocations(Animal animal) { var lodges = _lodgingRepository.GetAll(); var freeLodges = new List <Lodging>(); foreach (var lodge in lodges) { // Check if group lodging & castrated or Individual group if ((animal.Castrated && lodge.LodgingType == LodgingType.Group) || lodge.LodgingType == LodgingType.Individual) { // Check if lodging has free space if new animal is added && animal is of correct type if (lodge.CurrentCapacity + 1 != lodge.MaxCapacity && lodge.AnimalType == animal.AnimalType) { freeLodges.Add(lodge); } } } return(freeLodges); }
public IEnumerable <Lodging> GetAll() { // Add specific business logic here return(_lodgingRepository.GetAll()); }