public static char FavoriSoruEkle(int soruId, int kullaniciId) { char res = '*'; try { using (idDBEntities db = new idDBEntities()) { var favSoru = (from p in db.favoris where p.soruId == soruId && p.kullaniciId == kullaniciId select p).SingleOrDefault(); if (favSoru == null) { favori f = new favori(); f.soruId = soruId; f.kullaniciId = kullaniciId; db.favoris.Add(f); db.SaveChanges(); res = '+'; } else { db.favoris.Remove(favSoru); db.SaveChanges(); res = '-'; } } } catch (Exception) { res = '?'; } return(res); }
public static char SifreGuncelle(string eski, string yeni, int kulId) { char res = '*'; try { using (idDBEntities db = new idDBEntities()) { kullanici k = db.kullanicis.Find(kulId); eski = MD5Sifrele(eski); if (k.sifre == eski) { k.sifre = MD5Sifrele(yeni); db.SaveChanges(); res = '+'; } else { res = '-'; } } } catch { res = '?'; } return(res); }
public static int KayitOl(kullanici kullanici) { try { idDBEntities db = new idDBEntities(); var kul = (from k in db.kullanicis where k.kullaniciAdi == kullanici.kullaniciAdi select k).SingleOrDefault(); if (kul == null) { kullanici.sifre = MD5Sifrele(kullanici.sifre); db.kullanicis.Add(kullanici); db.SaveChanges(); return(0); // kayıt başarılı } else { return(1); // kayıt başarısız } } catch { return(2); // işlem başarısız } }
public static char CevapOnayla(int kullaniciId, int soruId, int cevapId) { char res = '*'; try { using (idDBEntities db = new idDBEntities()) { var tblCevap = (dynamic)null; var tblSoru = (from p in db.sorus where p.soruId == soruId && p.kullaniciId == kullaniciId select p).SingleOrDefault(); //sadece soruyu soran kullanıcı if (tblSoru != null) //tblsoru null ise tblcevap için gereksiz sorgulama yapılmamas { tblCevap = (from p in db.cevaps where p.cevapId == cevapId select p).SingleOrDefault(); // bu cevabı onaylayabilir } if (tblSoru != null && tblCevap != null) // tblcevap kontrolü öyle bir cevap yoksa ve aşağıdaki durumların patlama kontrolü { if (tblCevap.onayDurumu == false) { tblCevap.onayDurumu = true; db.SaveChanges(); res = '+'; } else { tblCevap.onayDurumu = false; db.SaveChanges(); res = '-'; } } else { res = '/'; } } } catch (Exception) { return('?'); } return(res); }
public static char BegeniCevap(int cevapId, int kullaniciId, int begeniTuruId) { char res = '*'; try { using (idDBEntities db = new idDBEntities()) { var tblBegeni = (from p in db.begenis where p.cevapId == cevapId && p.kullaniciId == kullaniciId select p).SingleOrDefault(); if (tblBegeni == null) { begeni b = new begeni(); b.cevapId = cevapId; b.kullaniciId = kullaniciId; b.begeniTuruId = begeniTuruId; db.begenis.Add(b); db.SaveChanges(); res = '+'; } else if (tblBegeni != null && tblBegeni.begeniTuruId != begeniTuruId) { tblBegeni.begeniTuruId = begeniTuruId; db.SaveChanges(); res = '/'; } else { db.begenis.Remove(tblBegeni); db.SaveChanges(); res = '-'; } } } catch { res = '?'; } return(res); }
public static bool KategoriEkle(kategori kategori) { try { using (idDBEntities db = new idDBEntities()) { db.kategoris.Add(kategori); db.SaveChanges(); return(true); } } catch { return(false); } }
public static string SoruEkle(soru soru) { try { using (idDBEntities db = new idDBEntities()) { db.sorus.Add(soru); db.SaveChanges(); return("+"); } } catch { return("-"); } }
public static bool CevabaYorumYaz(yorum yorum) { try { using (idDBEntities db = new idDBEntities()) { db.yorums.Add(yorum); db.SaveChanges(); return(true); } } catch { return(false); } }
public static bool SoruyaCevapYaz(cevap cevap) { try { using (idDBEntities db = new idDBEntities()) { db.cevaps.Add(cevap); db.SaveChanges(); return(true); } } catch { return(false); } }
public static bool EtiketEkle(etiket etiket) { try { using (idDBEntities db = new idDBEntities()) { db.etikets.Add(etiket); db.SaveChanges(); return(true); } } catch { return(false); } }