| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 | 
							- using Microsoft.EntityFrameworkCore;
 - using System;
 - using System.Collections.Generic;
 - using System.Linq;
 - using UnivateProperties_API.Containers.Property;
 - using UnivateProperties_API.Context;
 - using UnivateProperties_API.Model.Misc;
 - 
 - namespace UnivateProperties_API.Repository.Misc
 - {
 -     public class CarouselRepository : IRepository<Carousel>
 -     {
 -         private readonly DataContext dBContext;
 - 
 -         public CarouselRepository(DataContext _dBContext)
 -         {
 -             dBContext = _dBContext;
 -         }
 - 
 -         public List<Carousel> Get(Func<Carousel, bool> where)
 -         {
 -             var CarouselList = dBContext.Carousel.Where(where).ToList();
 - 
 -             foreach (var item in CarouselList)
 -             {
 -                 if (!string.IsNullOrEmpty(item.Image) && !item.Image.StartsWith("data:image"))
 -                     item.Image = ImageFormatter.ImageToBase64(item.Image);
 -             }
 - 
 -             return CarouselList;
 -         }
 - 
 -         public List<Carousel> GetAll()
 -         {            
 -             var CarouselList = dBContext.Carousel.ToList();
 - 
 -             foreach (var item in CarouselList)
 -             {
 -                 if (!string.IsNullOrEmpty(item.Image) && !item.Image.StartsWith("data:image"))
 -                     item.Image = ImageFormatter.ImageToBase64(item.Image);
 -             }
 - 
 -             return CarouselList;
 -         }
 - 
 -         public Carousel GetDetailed(Func<Carousel, bool> first)
 -         {
 -             return dBContext.Carousel.FirstOrDefault(first);
 -         }
 - 
 -         public List<Carousel> GetDetailedAll()
 -         {
 -             return dBContext.Carousel.ToList();
 -         }
 - 
 -         public void Insert(Carousel item)
 -         {
 -             dBContext.Carousel.Add(item);
 -             Save();
 -         }
 - 
 -         public void Insert(IEnumerable<Carousel> items)
 -         {
 -             foreach (var item in items)
 -             {
 -                 dBContext.Carousel.Add(item);
 -                 Save();
 -             }
 -         }
 - 
 -         public void Remove(Carousel item)
 -         {
 -             dBContext.Carousel.Remove(item);
 -             Save();
 -         }
 - 
 -         public void Remove(IEnumerable<Carousel> items)
 -         {
 -             foreach (var item in items)
 -             {
 -                 dBContext.Carousel.Remove(item);
 -                 Save();
 -             }
 -         }
 - 
 -         public void RemoveAtId(int item)
 -         {
 -             var Carousel = Get(x => x.Id == item).FirstOrDefault();
 -             if (Carousel != null)
 -             {
 -                 dBContext.Carousel.Remove(Carousel);
 -                 Save();
 -             }
 -         }
 - 
 -         public void Save()
 -         {
 -             dBContext.SaveChanges();
 -         }
 - 
 -         public void Update(Carousel item)
 -         {
 -             dBContext.Entry(item).State = EntityState.Modified;
 -             Save();
 -         }
 - 
 -         public int NewId()
 -         {
 -             // Not sure if properties need it
 -             return 0;
 -         }
 -     }
 - }
 
 
  |