Пример #1
0
        public ActionResult Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (KullaniciRepository repo = new KullaniciRepository())
                {
                    Kullanici durum = repo.Getir(x => x.KullaniciAdi == model.KullaniciAdi && x.Parola == model.Parola && x.Silindi == false);

                    if (durum != null)
                    {
                        //TempData["Mesaj"] = new TempDataDictionary { { "class", "alert alert-success" }, { "mesaj", "Başarılı." } };
                        //TempData["Mesaj"] = new TempDataDictionary { { "class", "alert alert-success" }, { "mesaj", "Başarılı." } };
                        Session["User"] = durum;

                        durum.SonGirisZamani = DateTime.Now;
                        repo.Guncelle(durum);
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        //TempData["Mesaj"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "mesaj", "Başarısız." } };
                        TempData["Mesaj"] = "Yanlış kullanıcı adı veya parola";
                        return(View());
                    }
                }
            }
            //TempData["Mesaj"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "mesaj", "Bilgileri eksiksiz giriniz." } };
            TempData["Mesaj"] = "LÜtfen bilgileri eksiksiz giriniz.";
            return(View());
        }
Пример #2
0
        public ActionResult Edit(int id, Kullanici model)
        {
            try
            {
                using (var repo = new KullaniciRepository())
                {
                    model.GuncellemeTarihi = DateTime.Now;
                    repo.Guncelle(model);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View(model));
            }
        }
Пример #3
0
        public ActionResult Delete(int id, FormCollection fc)
        {
            try
            {
                using (var repo = new KullaniciRepository())
                {
                    var model = repo.Getir(x => x.Id == id);
                    model.Silindi = true;
                    repo.Guncelle(model);
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #4
0
 public Kullanici KullaniciGuncelle(Kullanici entity)
 {
     try
     {
         using (var repo = new KullaniciRepository())
         {
             if (repo.Guncelle(entity))
             {
                 return(entity);
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw new Exception("KullaniciBusiness:KullaniciRepository:Güncelleme Hatası", ex);
     }
 }