public SubscriberService(UnitofWork uow)
 {
     _uow            = uow;
     _aboneRepo      = _uow.GetRepository <Abone>();
     _aboneDTO       = new AboneDTO();
     _giriscikisRepo = _uow.GetRepository <AboneGiriCikis>();
     _giriscikisDTO  = new AboneGirisCikisDTO();
     _odemeRepo      = _uow.GetRepository <AboneOdeme>();
     _odemeDTO       = new AboneOdemeDTO();
 }
        public bool SubscriberInputOutput(AboneGirisCikisDTO abone)
        {
            try
            {
                var entity = AutoMapper.Mapper.DynamicMap <AboneGiriCikis>(abone);
                _giriscikisRepo.Insert(entity);
                _uow.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw new Exception(ex.Message);
            }
        }
Beispiel #3
0
        public ActionResult AracPlakaOkumaModel(string Plaka, string Bolge, string Marka, string Kasa, string Model, string Renk)
        {
            int aracID;

            aracID = _aracService.GetCar(Plaka);
            if (aracID == 0)
            {
                AracDTO arac = new AracDTO();
                arac.Bolge = Bolge;
                arac.Plaka = Plaka;
                arac.Renk  = Renk;
                arac.Kasa  = Kasa;

                AracMarkaDTO marka = _aracService.GetCarBrand(Marka);
                if (marka != null)
                {
                    arac.MarkaID = marka.MarkaID;
                    AracModelDTO model = _aracService.GetCarModel(marka.MarkaID, Model.Split('_')[1]);
                    if (model != null)
                    {
                        arac.ModelID = model.ModelID;
                    }
                    else
                    {
                        AracModelDTO mo = new AracModelDTO();
                        mo.MarkaID = marka.MarkaID;
                        mo.Model   = Model.Split('_')[1];
                        int modelId = _aracService.CarModelInsert(mo);

                        arac.ModelID = modelId;
                    }
                }
                else
                {
                    AracMarkaDTO m = new AracMarkaDTO();
                    m.Marka = Marka;
                    int markaId = _aracService.CarBrandInsert(m);

                    arac.MarkaID = markaId;

                    AracModelDTO mo = new AracModelDTO();
                    mo.MarkaID = markaId;
                    mo.Model   = Model;
                    int modelId = _aracService.CarModelInsert(mo);

                    arac.ModelID = modelId;
                }

                aracID = _aracService.Insert(arac);
            }
            if (!_aracService.GetBlackListCarControl(aracID))
            {
                AboneDTO abone = _aboneService.GetSubscriber(aracID);
                if (abone != null)
                {
                    AboneGirisCikisDTO kontrol = new AboneGirisCikisDTO();
                    kontrol.AboneId = abone.AboneID;
                    kontrol.Durum   = true;
                    kontrol.Tarih   = DateTime.Now;
                    bool durum = _aboneService.SubscriberInputOutput(kontrol);
                    if (durum == true)
                    {
                        var islemdurum = abone.Islem;
                        if (islemdurum == "Giriş Yaptı")
                        {
                            abone.Islem = "Çıkış Yaptı";
                        }
                        else if (islemdurum == "Çıkış Yaptı")
                        {
                            abone.Islem = "Giriş Yaptı";
                        }
                        _aboneService.Update(abone);
                    }
                }
                else
                {
                    MusteriDTO musteri = new MusteriDTO();
                    musteri.HizmetTuru = "Park";
                    if (musteri.Aciklama == null)
                    {
                        musteri.Aciklama = "Açıklama Girilmedi.";
                    }
                    if (musteri.Tutar == null)
                    {
                        musteri.Tutar = 0;
                    }

                    int            musteriID = _musteriService.CustomerInsert(musteri, aracID);
                    MusteriParkDTO park      = new MusteriParkDTO();
                    park.MusteriID   = musteriID;
                    park.GirisTarihi = DateTime.Now;
                    _musteriService.CustomerParkInsert(park, musteriID);
                }
            }
            else
            {
                return(Json("fail", JsonRequestBehavior.AllowGet));
            }

            return(Json("success", JsonRequestBehavior.AllowGet));
        }