Exemplo n.º 1
0
        // LEVEL: CAMPGROUND  /////////////////////////////////////////
        private int[] GetCampgroundAvailability_View(int campgroundID, DateTime startDate, DateTime endDate)
        {
            CampgroundSqlDAL campDAL            = new CampgroundSqlDAL(DatabaseConnection);
            IList <Campsite> availableCampsites = campDAL.CampgroundAvailability(campgroundID, startDate, endDate);
            int lengthOfStay = (int)(endDate - startDate).TotalDays;

            Campground campground = campDAL.CampgroundDetails(campgroundID);

            if (availableCampsites.Count > 0)
            {
                int[]   output = new int[availableCampsites.Count];
                decimal cost   = 0;
                decimal fee    = 0;
                Console.WriteLine(
                    "Campground".PadRight(30)
                    + "Site No.".PadRight(15)
                    + "Max Occup.".ToString().PadRight(15)
                    + "Accessible".PadRight(15)
                    + "RV Len".PadRight(15)
                    + "Utility".PadRight(15)
                    + "Cost".PadLeft(20));

                int i = 0;
                foreach (Campsite campsite in availableCampsites)
                {
                    output[i] = campsite.Site_Number;
                    fee       = campground.Daily_Fee;
                    cost      = fee * lengthOfStay;
                    this.PrintCampsiteAvailability(
                        campground.Name,
                        campsite.Site_Number,
                        campsite.Max_Occupancy,
                        campsite.IsAccessible,
                        campsite.Max_RV_Length,
                        campsite.HasUtilities,
                        cost);
                    i++;
                }

                return(output);
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
                return(new int[0]);
            }
        }