Esempio n. 1
0
 public bool ArizaEkle(Arızalar ariza)
 {
     try
     {
         db.Arızalar.Add(ariza);
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public bool KullaniciEkle(Kullanicilar kullanicilar)
        {
            bool res = false;

            try
            {
                db.Kullanicilar.Add(kullanicilar);
                db.SaveChanges();
                res = true;
            }
            catch (Exception)
            {
                res = false;
            }
            return(res);
        }
        public bool Kategori2Ekle(Kategori_2 Kategori_2)
        {
            bool res = false;

            try
            {
                db.Kategori_2.Add(Kategori_2);
                db.SaveChanges();
                res = true;
            }
            catch (Exception)
            {
                res = false;
            }
            return(res);
        }
        public bool PersonelEkle(Personel personel)
        {
            bool res = false;

            try
            {
                db.Personel.Add(personel);
                db.SaveChanges();
                res = true;
            }
            catch (Exception)
            {
                res = false;
            }
            return(res);
        }
        public bool Kategori1Ekle(Kategori_1 kategori_1)
        {
            bool res = false;

            try
            {
                db.Kategori_1.Add(kategori_1);
                db.SaveChanges();
                res = true;
            }
            catch (Exception)
            {
                res = false;
            }
            return(res);
        }
        public bool KullaniciGrupEkle(KullaniciGruplari kullaniciGruplari)
        {
            bool res = false;

            try
            {
                db.KullaniciGruplari.Add(kullaniciGruplari);
                db.SaveChanges();
                res = true;
            }
            catch (Exception)
            {
                res = false;
            }
            return(res);
        }
        public bool EkipEkle(Ekipler ekip)
        {
            bool res = false;

            try
            {
                db.Ekipler.Add(ekip);
                db.SaveChanges();
                res = true;
            }catch (Exception)
            {
                res = false;
            }
            return(res);
        }
Esempio n. 8
0
        public Tokens Login(Kullanicilar kullanici)
        {
            Kullanicilar isThereUser = null;

            using (var db1 = new dbATUEntities())
            {
                db.Configuration.LazyLoadingEnabled = false;

                /* isThereUser = (from kl in db1.Kullanicilar
                 *               where kl.KullaniciAdi == kullanici.KullaniciAdi && kl.Sifre == kullanici.Sifre
                 *               select kl)
                 *               .FirstOrDefault<Kullanicilar>();*/

                isThereUser = db.Kullanicilar.Where(a => a.KullaniciAdi == kullanici.KullaniciAdi &&
                                                    a.Sifre == kullanici.Sifre)
                              .Include(p => p.Personel)
                              .Include(p => p.KullaniciGruplari)
                              .Include(p => p.Personel.Ekipler)
                              .FirstOrDefault();


                /*select new Kullanicilar()
                 * {
                 * KullaniciAdi = kl.KullaniciAdi,
                 * KullaniciNo = kl.KullaniciNo,
                 * PersonelNo = kl.PersonelNo,
                 * KullaniciGrubu = kl.KullaniciGrubu
                 *
                 * }*/
            }

            if (isThereUser != null)
            {
                Tokens res = new Tokens();


                res.Kullanicilar = isThereUser;


                res.KullaniciNo = isThereUser.KullaniciNo;
                //    PersonelDAL personelDAL = new PersonelDAL();
                res.Token        = RandomString(40);
                res.Kullanicilar = isThereUser;
                //  res.Kullanicilar.Personel = personelDAL.getPersonelById(isThereUser.PersonelNo);
                db.Entry(res.Kullanicilar).State = System.Data.Entity.EntityState.Modified;
                if (isThereUser.Tokens.Count == 0)
                {
                    db.Tokens.Add(res);
                    db.SaveChanges();
                }
                else
                {
                    Tokens tokens = isThereUser.Tokens.First <Tokens>();
                    isThereUser.Tokens.Clear();
                    res.Token = tokens.Token;
                }

                res.Kullanicilar.KullaniciAdi      = "";
                res.Kullanicilar.Sifre             = "";
                res.Kullanicilar.Personel.KimlikNo = 0;
                return(res);
            }
            else
            {
                return(null);
            }
        }