Example #1
0
 /// <summary>
 /// Adds a new user to the database
 /// </summary>
 /// <param name="userId">UserID matching the Identity generated UserID</param>
 /// <param name="username">Name of the user</param>
 /// <returns>True or false depending on if the operation was successful</returns>
 public bool AddUser(string userId, string username)
 {
     try {
         User newUser = new User();
         newUser.UserID   = userId;
         newUser.Username = username;
         _communityContext.Add(newUser);
         _communityContext.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
        public ActionResult Kayit(Kullanici k, string tel, string fak)
        {
            Kullanici us = db.Kullanici.Where(x => x.ogrMail == k.ogrMail).FirstOrDefault();

            if (us != null)
            {
                ViewBag.Hata = "Bu mail adresi ile bir kayıt bulunmaktadır.";
                return(View());
            }

            k.adi         = Functions.IlkHarfleriBuyut(k.adi);
            k.soyadi      = Functions.IlkHarfleriBuyut(k.soyadi);
            k.kayitTarihi = DateTime.Now;

            Basvuru b = new Basvuru();

            b.kullanıcıID = k.ID;
            b.kapat       = false;
            b.adimNo      = 1;

            Guncelle g = new Guncelle();

            g.kullanıcıID = k.ID;
            g.kapat       = false;
            g.adimNo      = 1;

            GOgrenciListesi gol = new GOgrenciListesi();

            gol.adi        = k.adi;
            gol.soyadi     = k.soyadi;
            gol.tc         = k.tc;
            gol.ogrNo      = k.ogrNo;
            gol.tel        = tel;
            gol.GuncelleID = g.ID;
            gol.mail       = k.ogrMail;
            gol.fak        = fak;

            OgrenciListesi ol = new OgrenciListesi();

            ol.adi       = k.adi;
            ol.soyadi    = k.soyadi;
            ol.tc        = k.tc;
            ol.ogrNo     = k.ogrNo;
            ol.tel       = tel;
            ol.basvuruID = b.ID;
            ol.mail      = k.ogrMail;
            ol.fak       = fak;


            db.Kullanici.Add(k);
            db.Guncelle.Add(g);
            db.GOgrenciListesi.Add(gol);
            db.Basvuru.Add(b);
            db.OgrenciListesi.Add(ol);
            db.SaveChanges();
            return(RedirectToAction("GirisYap", "Kullanici", k));
        }
 /// <summary>
 /// Adds a new message to the database
 /// </summary>
 /// <param name="title">Message title</param>
 /// <param name="text">Message body</param>
 /// <param name="senderUser">Sender of the message</param>
 /// <param name="receiverUser">Receiver of the message</param>
 /// <returns>True or false depending on if the operation was successful</returns>
 public bool AddMessage(string title, string text, User senderUser, User receiverUser)
 {
     try {
         Message newMessage = new Message();
         newMessage.Title        = title;
         newMessage.Text         = text;
         newMessage.SenderUser   = senderUser;
         newMessage.ReceiverUser = receiverUser;
         if (!senderUser.Equals(receiverUser))
         {
             _communityContext.Attach(receiverUser);
         }
         _communityContext.Attach(senderUser);
         _communityContext.Add(newMessage);
         _communityContext.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
        public ActionResult Sil(int id)
        {
            Admin admin  = db.Admin.Where(x => x.ID == id).FirstOrDefault();
            Admin admin2 = (Admin)Session["Admin"];

            if (admin != null)
            {
                if (admin.ID == admin2.ID)
                {
                    return(Json(2));
                }
                db.Admin.Remove(admin);
                db.SaveChanges();
                return(Json(1));
            }
            return(Json(0));
        }
Example #5
0
        public ActionResult form1(GuncelleForm1 guncelle)
        {
            Kullanici k = (Kullanici)Session["Kullanici"];
            Guncelle  g = db.Guncelle.Where(x => x.kullanıcıID == k.ID).FirstOrDefault();

            g.toplulukAdi  = guncelle.toplulukAdi;
            g.baskanAdi    = guncelle.baskanAdi;
            g.baskanSoyadi = guncelle.baskanSoyadi;


            GDanisman d1 = new GDanisman();
            GDanisman d2 = new GDanisman();

            if (g.adimNo == 1)
            {
                if (guncelle.Kontrol == true)
                {
                    d2.aktif = true;
                    d1.aktif = false;
                }
                else
                {
                    d1.aktif = true;
                    d2.aktif = false;
                }

                d1.adi           = guncelle.adi1;
                d1.soyadi        = guncelle.soyadi1;
                d1.unvan         = guncelle.unvan1;
                d1.akademikBirim = guncelle.akademikBirim1;
                d1.GuncelleID    = g.ID;


                d2.adi           = guncelle.adi2;
                d2.soyadi        = guncelle.soyadi2;
                d2.unvan         = guncelle.unvan2;
                d2.akademikBirim = guncelle.akademikBirim2;
                d2.GuncelleID    = g.ID;
                g.adimNo         = 2;
            }
            else
            {
                d1 = db.GDanisman.Where(x => x.GuncelleID == g.ID && x.aktif == true).FirstOrDefault();
                d2 = db.GDanisman.Where(x => x.GuncelleID == g.ID && x.aktif == false).FirstOrDefault();

                if (guncelle.Kontrol == true)
                {
                    d2.aktif = true;
                    d1.aktif = false;
                }
                else
                {
                    d1.aktif = true;
                    d2.aktif = false;
                }

                d1.adi           = guncelle.adi1;
                d1.soyadi        = guncelle.soyadi1;
                d1.unvan         = guncelle.unvan1;
                d1.akademikBirim = guncelle.akademikBirim1;
                d1.GuncelleID    = g.ID;

                d2.adi           = guncelle.adi2;
                d2.soyadi        = guncelle.soyadi2;
                d2.unvan         = guncelle.unvan2;
                d2.akademikBirim = guncelle.akademikBirim2;
                d2.GuncelleID    = g.ID;
            }

            db.GDanisman.Add(d1);
            db.GDanisman.Add(d2);
            db.SaveChanges();

            return(View(g));
        }
Example #6
0
        public ActionResult form1(Basvuru basvuru)
        {
            Kullanici k = (Kullanici)Session["Kullanici"];
            Basvuru   b = db.Basvuru.Where(x => x.kullanıcıID == k.ID).FirstOrDefault();

            b.toplulukAdi  = basvuru.toplulukAdi;
            b.toplulukAmac = basvuru.toplulukAmac;
            if (b.adimNo == 1)
            {
                b.adimNo = 2;
            }
            db.SaveChanges();
            return(View(basvuru));
        }