コード例 #1
0
 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);
     }
 }
コード例 #2
0
ファイル: AnimalService.cs プロジェクト: Wouter-J/SSWDI
        /// <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);
        }
コード例 #3
0
 public IEnumerable <Lodging> GetAll()
 {
     // Add specific business logic here
     return(_lodgingRepository.GetAll());
 }