예제 #1
0
 public EkleController()
 {
     _ekleModel     = new EkleModel();
     _aktifPasif    = new AktifPasifModel();
     _listele       = new ListeleModel();
     _guncelleModel = new GuncelleModel();
 }
        public IActionResult Guncelle(int Id)
        {
            var           gelenKitap = _kitapService.GetById3(Id);
            GuncelleModel model      = new GuncelleModel
            {
                KitapAdi   = gelenKitap.KitapAdi,
                KategoriId = gelenKitap.KategoriId,
                Resim      = gelenKitap.Resim,
                Puan       = gelenKitap.Puan,
                Id         = gelenKitap.Id,
                Yazar      = gelenKitap.Yazar,
                YorumId    = gelenKitap.YorumId
            };

            return(View(model));
        }
        public IActionResult Guncelle(GuncelleModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var guncellenecekKitap = _kitapService.GetById3(model.Id);
            var guncellenecekYorum = _yorumlarService.GetById2(model.Id);


            TempData.Add("message", "Kitap Başarı ile Güncellendi.!");


            guncellenecekKitap.KitapAdi = model.KitapAdi;


            guncellenecekKitap.Puan = model.Puan;

            guncellenecekKitap.Yazar = model.Yazar;

            guncellenecekKitap.Resim = model.Resim;

            guncellenecekKitap.YorumId = model.YorumId;
            guncellenecekKitap.YorumId = model.YorumId;

            guncellenecekKitap.KategoriAdi = model.Kategori;

            guncellenecekKitap.KategoriId = model.KategoriId;


            _kitapService.Update(guncellenecekKitap);
            _yorumlarService.Update(guncellenecekYorum);


            return(RedirectToAction("Guncelle", controllerName: "Admin"));
        }