Ejemplo n.º 1
0
        public AracDTO GetById(int id)
        {
            using (AracRepository aracRepo = new AracRepository())
            {
                try
                {
                    var entity  = aracRepo.GetById(id);
                    var aracdto = new AracDTO();
                    aracdto.airbag       = entity.airbag;
                    aracdto.aracID       = entity.aracID;
                    aracdto.bagajHacmi   = entity.bagajHacmi;
                    aracdto.ehliyetYasi  = entity.ehliyetYasi;
                    aracdto.gunlukFiyat  = entity.gunlukFiyat;
                    aracdto.gunlukKm     = entity.gunlukKm;
                    aracdto.KM           = entity.KM;
                    aracdto.koltukSayisi = entity.koltukSayisi;
                    aracdto.marka        = entity.marka;
                    aracdto.model        = entity.model;
                    aracdto.sirketAdi    = entity.Sirket.sirketAdi;
                    aracdto.sirketID     = entity.sirketID;
                    aracdto.yasSiniri    = entity.yasSiniri;

                    return(aracdto);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public List <AracDTO> GetAllCars(int sirketId)
        {
            using (AracRepository aracRepository = new AracRepository())
            {
                List <AracDTO> Araclar = new List <AracDTO>();

                var model = aracRepository.Get();
                foreach (var entity in model.ToList())
                {
                    if (entity.sirketID == sirketId)
                    {
                        var aracdto = new AracDTO();
                        aracdto.airbag       = entity.airbag;
                        aracdto.aracID       = entity.aracID;
                        aracdto.bagajHacmi   = entity.bagajHacmi;
                        aracdto.ehliyetYasi  = entity.ehliyetYasi;
                        aracdto.gunlukFiyat  = entity.gunlukFiyat;
                        aracdto.gunlukKm     = entity.gunlukKm;
                        aracdto.KM           = entity.KM;
                        aracdto.koltukSayisi = entity.koltukSayisi;
                        aracdto.marka        = entity.marka;
                        aracdto.model        = entity.model;
                        aracdto.sirketAdi    = entity.Sirket.sirketAdi;
                        aracdto.sirketID     = entity.sirketID;
                        aracdto.yasSiniri    = entity.yasSiniri;
                        Araclar.Add(aracdto);
                    }
                }
                return(Araclar);
            }
        }
Ejemplo n.º 3
0
 public void Delete(int id)
 {
     using (AracRepository aracRepo = new AracRepository())
     {
         try
         {
             aracRepo.Delete(id);
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
 }
Ejemplo n.º 4
0
 public void Update(Arac model)
 {
     using (AracRepository aracRepo = new AracRepository())
     {
         try
         {
             aracRepo.Update(model);
         }
         catch (Exception ex)
         {
             throw;
         }
     }
 }
Ejemplo n.º 5
0
 public Arac AracPlakaSec(string plaka)
 {
     try
     {
         Arac responseEntitiy = null;
         using (var repo = new AracRepository())
         {
             responseEntitiy = repo.PlakaSec(plaka);
         }
         return(responseEntitiy);
     }
     catch (Exception ex)
     {
         throw new Exception("AracBusiness:AracRepository:Seçme Hatası", ex);
     }
 }
Ejemplo n.º 6
0
 public Arac AracIdSec(int AracId)
 {
     try
     {
         Arac responseEntitiy = null;
         using (var repo = new AracRepository())
         {
             responseEntitiy = repo.IdSec(AracId);
         }
         return(responseEntitiy);
     }
     catch (Exception ex)
     {
         throw new Exception("AracBusiness:AracRepository:Seçme Hatası", ex);
     }
 }
Ejemplo n.º 7
0
 public bool AracGuncelle(Arac arac)
 {
     try
     {
         bool isSuccess;
         using (var repo = new AracRepository())
         {
             isSuccess = repo.Update(arac);
         }
         return(isSuccess);
     }
     catch (Exception ex)
     {
         LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
         throw new Exception("Business:AracBusiness::AracGuncelle::Hata Oluştu.", ex);
     }
 }
Ejemplo n.º 8
0
 public bool DeleteAracById(int ID)
 {
     try
     {
         bool isSuccess;
         using (var repo = new AracRepository())
         {
             isSuccess = repo.DeletedById(ID);
         }
         return(isSuccess);
     }
     catch (Exception ex)
     {
         LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
         throw new Exception("BusinessLogic:AracBusiness::AracCustomer::Error occured.", ex);
     }
 }
Ejemplo n.º 9
0
 public bool UpdateArac(Arac entity)
 {
     try
     {
         bool isSuccess;
         using (var repo = new AracRepository())
         {
             isSuccess = repo.Update(entity);
         }
         return(isSuccess);
     }
     catch (Exception ex)
     {
         LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
         throw new Exception("BusinessLogic:AracBusiness::UpdateArac::Error occured.", ex);
     }
 }
Ejemplo n.º 10
0
 public bool AracSilById(int aracID)
 {
     try
     {
         bool isSuccess;
         using (var repo = new AracRepository())
         {
             isSuccess = repo.DeletedById(aracID);
         }
         return(isSuccess);
     }
     catch (Exception ex)
     {
         LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
         throw new Exception("Business:AracBusiness::AracSilById::Hata Oluştu.", ex);
     }
 }
Ejemplo n.º 11
0
 public Arac AracIdSil(int AracId)
 {
     try
     {
         using (var repo = new AracRepository())
         {
             if (repo.IdSil(AracId))
             {
                 return(repo.IdSec(AracId));
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw new Exception("AracBusiness:AracRepository:Silme Hatası", ex);
     }
 }
Ejemplo n.º 12
0
 public Arac AracGuncelle(Arac entity)
 {
     try
     {
         using (var repo = new AracRepository())
         {
             if (repo.Guncelle(entity))
             {
                 return(entity);
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw new Exception("AracBusiness:AracRepository:Güncelleme Hatası", ex);
     }
 }
Ejemplo n.º 13
0
 public Arac AracKirala(Arac entity)
 {
     try
     {
         using (var repo = new AracRepository())
         {
             //var entity = repo.IdSec(arac.AracID);
             if (repo.Kirala(entity))
             {
                 return(entity);
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw new Exception("AracBusiness:AracRepository:Kiralama Hatası", ex);
     }
 }
Ejemplo n.º 14
0
        public List <AracDTO> GetForUsers(DateTime baslangic, DateTime bitis, int sirketId)
        {
            using (AracRepository aracRepository = new AracRepository())
            {
                List <AracDTO> Araclar = new List <AracDTO>();

                var model = aracRepository.Get().Where(x => x.sirketID == sirketId);// tüm araçları aldık

                var kiralikaracRepo = new KiralikAracRepository();
                var kiralikmodels   = kiralikaracRepo.Get().Where(x => x.Arac.sirketID == sirketId);


                foreach (var entity in model)
                {
                    var test =
                        kiralikmodels.Where
                            (x => x.aracID == entity.aracID && (x.bitisTarihi > baslangic || x.bitisTarihi == baslangic) && x.baslangicTarihi < bitis).ToList();
                    if (test.Count > 0)
                    {
                        continue;
                    }
                    else
                    {
                        var aracdto = new AracDTO();
                        aracdto.airbag       = entity.airbag;
                        aracdto.aracID       = entity.aracID;
                        aracdto.bagajHacmi   = entity.bagajHacmi;
                        aracdto.ehliyetYasi  = entity.ehliyetYasi;
                        aracdto.gunlukFiyat  = entity.gunlukFiyat;
                        aracdto.gunlukKm     = entity.gunlukKm;
                        aracdto.KM           = entity.KM;
                        aracdto.koltukSayisi = entity.koltukSayisi;
                        aracdto.marka        = entity.marka;
                        aracdto.model        = entity.model;
                        aracdto.sirketAdi    = entity.Sirket.sirketAdi;
                        aracdto.sirketID     = entity.sirketID;
                        aracdto.yasSiniri    = entity.yasSiniri;
                        Araclar.Add(aracdto);
                    }
                }
                return(Araclar);
            }
        }
Ejemplo n.º 15
0
 public Arac AracSecById(int aracID)
 {
     try
     {
         Arac secilenArac;
         using (var repo = new AracRepository())
         {
             secilenArac = repo.SelectedById(aracID);
             if (secilenArac == null)
             {
                 throw new NullReferenceException("Girilen aracID bulunamadi!");
             }
         }
         return(secilenArac);
     }
     catch (Exception ex)
     {
         LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
         throw new Exception("Business:AracBusiness::AracSecById::Hata Oluştu.", ex);
     }
 }
Ejemplo n.º 16
0
        public List <Arac> SelectAllArac()
        {
            var responseEntities = new List <Arac>();

            try
            {
                using (var repo = new AracRepository())
                {
                    foreach (var entity in repo.SelectAll())
                    {
                        responseEntities.Add(entity);
                    }
                }
                return(responseEntities);
            }
            catch (Exception ex)
            {
                LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
                throw new Exception("BusinessLogic:AracBusiness::SelectAllCArac::Error occured.", ex);
            }
        }
Ejemplo n.º 17
0
 public Arac SelectAracById(int Id)
 {
     try
     {
         Arac responseEntitiy;
         using (var repo = new AracRepository())
         {
             responseEntitiy = repo.SelectedById(Id);
             if (responseEntitiy == null)
             {
                 throw new NullReferenceException("Sirket doesnt exists!");
             }
         }
         return(responseEntitiy);
     }
     catch (Exception ex)
     {
         LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
         throw new Exception("BusinessLogic:AracBusiness::SelectAracById::Error occured.", ex);
     }
 }
Ejemplo n.º 18
0
        public List <Arac> SelectAllArac()
        {
            var aracListesi = new List <Arac>();

            try
            {
                using (var repo = new AracRepository())
                {
                    foreach (var arac in repo.SelectAll())
                    {
                        aracListesi.Add(arac);
                    }
                }
                return(aracListesi);
            }
            catch (Exception ex)
            {
                LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
                throw new Exception("Business:AracBusiness::SelectAllArac::Hata Oluştu.", ex);
            }
        }
Ejemplo n.º 19
0
 public bool Add(Arac model)
 {
     using (AracRepository aracRepo = new AracRepository())
     {
         try
         {
             if (aracRepo.Add(model))
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
 }
Ejemplo n.º 20
0
        public List <Arac> AracHepsiniSec()
        {
            var responseEntities = new List <Arac>();

            try
            {
                using (var repo = new AracRepository())
                {
                    foreach (var entity in repo.HepsiniSec())
                    {
                        responseEntities.Add(entity);
                    }
                }
                if (responseEntities == null)
                {
                    return(responseEntities);
                }
                return(responseEntities);
            }
            catch (Exception ex)
            {
                throw new Exception("AracBusiness:AracRepository:Hepsini Seçme Hatası", ex);
            }
        }
Ejemplo n.º 21
0
 public UnitOfWork(AracContext context)
 {
     _aracContext   = context;
     AracRepository = new AracRepository(_aracContext);
 }