Пример #1
0
        //Proje oluşturma
        public JsonResult ProjeEkle(tblProje proje)
        {
            proje.aktifMi = true;
            char x = TarihKontrol(Convert.ToDateTime(proje.baslangicTarihi), Convert.ToDateTime(proje.olusturmaTarihi), Convert.ToDateTime(proje.bitisTarihi));

            if (x != '-')
            {
                return(Json(x));
            }
            int s = ProjeIslem.ProjeEkle(proje);

            if (s == 0)
            {
                KullaniciProjeRol kpr = new KullaniciProjeRol
                {
                    projeId     = proje.projeId,
                    kullaniciId = int.Parse(Session["kulId"].ToString()),
                    rolId       = 1
                };
                KullaniciProjeEkle(kpr);
                Logar lg = new Logar((int)proje.olusturanKullaniciId, " Tarihte Proje Ekledi");
                return(Json("+"));
            }
            else
            {
                return(Json("-"));
            }
        }
Пример #2
0
 // kişi atama
 public static int KullaniciProjeEkle(KullaniciProjeRol veri)
 {
     try
     {
         using (BuyutecDBEntities db = new BuyutecDBEntities())
         {
             var sonuc = (from p in db.tblKullaniciProjeRols where p.projeId == veri.projeId && p.kullaniciId == veri.kullaniciId && p.rolId == veri.rolId select p).SingleOrDefault();
             if (sonuc == null)
             {
                 //var rolvarmi=(from p in db.tblKullaniciProjeRols where )
                 tblKullaniciProjeRol kp = new tblKullaniciProjeRol
                 {
                     projeId     = veri.projeId,
                     kullaniciId = veri.kullaniciId,
                     rolId       = veri.rolId
                 };
                 db.tblKullaniciProjeRols.Add(kp);
                 db.SaveChanges();
                 return(0);
             }
             else
             {
                 return(2);
             }
         }
     }
     catch
     {
         return(1);
     }
 }
Пример #3
0
        //kullanıcıları projeye eklemek.
        public JsonResult KullaniciProjeEkle(KullaniciProjeRol veri)
        {
            veri.projeId = projeDetayId;
            var kpEkle = ProjeIslem.KullaniciProjeEkle(veri);

            if (kpEkle == 0)
            {
                return(Json(kpEkle));
            }
            return(Json('-'));
        }
Пример #4
0
        /// <summary>
        /// Projeyi sisteme kaydeder.
        /// </summary>
        /// <param name="proje">Kaydedilecek proje.</param>
        /// <returns>Proje kaydetme durumunu döndürür</returns>
        public JsonResult ProjeKaydet(Proje proje)
        {
            try
            {
                proje.OlusturmaTarihi = DateTime.Now;
                proje.AktifMi         = true;
                db.Proje.Add(proje);

                var sahip = (from s in db.Kullanici
                             where s.ID == proje.ProjeSahibiID
                             select s).SingleOrDefault();
                var yonetici = (from y in db.Kullanici
                                where y.ID == proje.YoneticiID
                                select y).SingleOrDefault();
                var yoneticiRol = (from r in db.Rol
                                   where r.RolAdi == "Yönetici"
                                   select r).SingleOrDefault();

                KullaniciProjeRol kpr = new KullaniciProjeRol()
                {
                    Kullanici = yonetici,
                    Proje     = proje,
                    Rol       = yoneticiRol
                };
                db.KullaniciProjeRol.Add(kpr);

                if (proje.ProjeSahibiID != proje.YoneticiID)
                {
                    var musteriRol = (from r in db.Rol
                                      where r.RolAdi == "Müşteri"
                                      select r).SingleOrDefault();
                    KullaniciProjeRol kpr2 = new KullaniciProjeRol()
                    {
                        Kullanici = sahip,
                        Proje     = proje,
                        Rol       = musteriRol
                    };
                    db.KullaniciProjeRol.Add(kpr2);
                }

                db.SaveChanges();
                return(Json("Ekleme başarılı."));
            }
            catch
            {
                return(Json("Ekleme başarısız."));
            }
        }
Пример #5
0
 /// <summary>
 /// Projeye kullanıcı atar.
 /// </summary>
 /// <param name="kpr">Eklenecek rol</param>
 /// <returns>Kayıt durumunu döndürür</returns>
 public JsonResult ProjeyeAta(KullaniciProjeRol kpr)
 {
     try
     {
         var rolDurum = (from r in db.KullaniciProjeRol
                         where r.KullaniciID == kpr.KullaniciID && r.ProjeID == kpr.ProjeID && r.RolID == kpr.RolID
                         select r).SingleOrDefault();
         if (rolDurum == null)
         {
             db.KullaniciProjeRol.Add(kpr);
             db.SaveChanges();
             return(Json("Kayıt başarılı."));
         }
         else
         {
             return(Json("Kayıt başarısız."));
         }
     }
     catch
     {
         return(Json("Kayıt başarısız."));
     }
 }