|  | @@ -2,13 +2,14 @@
 | 
		
	
		
			
			| 2 | 2 |  using System;
 | 
		
	
		
			
			| 3 | 3 |  using System.Collections.Generic;
 | 
		
	
		
			
			| 4 | 4 |  using System.Linq;
 | 
		
	
		
			
			|  | 5 | +using UnivateProperties_API.Containers.Misc;
 | 
		
	
		
			
			| 5 | 6 |  using UnivateProperties_API.Containers.Property;
 | 
		
	
		
			
			| 6 | 7 |  using UnivateProperties_API.Context;
 | 
		
	
		
			
			| 7 | 8 |  using UnivateProperties_API.Model.Misc;
 | 
		
	
		
			
			| 8 | 9 |  
 | 
		
	
		
			
			| 9 | 10 |  namespace UnivateProperties_API.Repository.Misc
 | 
		
	
		
			
			| 10 | 11 |  {
 | 
		
	
		
			
			| 11 |  | -    public class CarouselRepository : IRepository<Carousel>
 | 
		
	
		
			
			|  | 12 | +    public class CarouselRepository : ICarouselRepository
 | 
		
	
		
			
			| 12 | 13 |      {
 | 
		
	
		
			
			| 13 | 14 |          private readonly DataContext dBContext;
 | 
		
	
		
			
			| 14 | 15 |  
 | 
		
	
	
		
			
			|  | @@ -109,5 +110,42 @@ namespace UnivateProperties_API.Repository.Misc
 | 
		
	
		
			
			| 109 | 110 |              // Not sure if properties need it
 | 
		
	
		
			
			| 110 | 111 |              return 0;
 | 
		
	
		
			
			| 111 | 112 |          }
 | 
		
	
		
			
			|  | 113 | +
 | 
		
	
		
			
			|  | 114 | +        public List<CarouselList> GetCarouselItems()
 | 
		
	
		
			
			|  | 115 | +        {
 | 
		
	
		
			
			|  | 116 | +            List<CarouselList> list = new List<CarouselList>();
 | 
		
	
		
			
			|  | 117 | +            var CarouselList = dBContext.Carousel.ToList();
 | 
		
	
		
			
			|  | 118 | +
 | 
		
	
		
			
			|  | 119 | +            foreach (var item in CarouselList)
 | 
		
	
		
			
			|  | 120 | +            {
 | 
		
	
		
			
			|  | 121 | +                if (!string.IsNullOrEmpty(item.Image) && !item.Image.StartsWith("data:image"))
 | 
		
	
		
			
			|  | 122 | +                    item.Image = ImageFormatter.ImageToBase64(item.Image);
 | 
		
	
		
			
			|  | 123 | +
 | 
		
	
		
			
			|  | 124 | +                var carItem = new CarouselList()
 | 
		
	
		
			
			|  | 125 | +                {
 | 
		
	
		
			
			|  | 126 | +                    Image = item.Image,
 | 
		
	
		
			
			|  | 127 | +                    Header = item.Header
 | 
		
	
		
			
			|  | 128 | +                };
 | 
		
	
		
			
			|  | 129 | +                if (item.PropertyId > 0)
 | 
		
	
		
			
			|  | 130 | +                {
 | 
		
	
		
			
			|  | 131 | +                    var property = dBContext.Properties.Include("Province").Include("City").Include("Suburb").Where(p => p.Id == item.PropertyId).FirstOrDefault();
 | 
		
	
		
			
			|  | 132 | +                    carItem.Address = string.Format("{0}, {1} <br/>{2}", property.Suburb.Description, property.City.Description, property.AddressLine3);
 | 
		
	
		
			
			|  | 133 | +                    carItem.IsProperty = true;
 | 
		
	
		
			
			|  | 134 | +                }
 | 
		
	
		
			
			|  | 135 | +                if (item.TimeshareId > 0)
 | 
		
	
		
			
			|  | 136 | +                {
 | 
		
	
		
			
			|  | 137 | +                    var timeshare = dBContext.Weeks.Where(t => t.Id == item.TimeshareId).FirstOrDefault();
 | 
		
	
		
			
			|  | 138 | +                    carItem.Bedrooms = timeshare.Bedrooms;
 | 
		
	
		
			
			|  | 139 | +                    carItem.Sleeps = timeshare.MaxSleep;
 | 
		
	
		
			
			|  | 140 | +                    carItem.Arrival = timeshare.ArrivalDate;
 | 
		
	
		
			
			|  | 141 | +                    carItem.Departure = timeshare.DepartureDate;
 | 
		
	
		
			
			|  | 142 | +                    carItem.IsProperty = false;
 | 
		
	
		
			
			|  | 143 | +                }
 | 
		
	
		
			
			|  | 144 | +
 | 
		
	
		
			
			|  | 145 | +                list.Add(carItem);
 | 
		
	
		
			
			|  | 146 | +            }
 | 
		
	
		
			
			|  | 147 | +
 | 
		
	
		
			
			|  | 148 | +            return list;
 | 
		
	
		
			
			|  | 149 | +        }
 | 
		
	
		
			
			| 112 | 150 |      }
 | 
		
	
		
			
			| 113 | 151 |  }
 |