public string ConnectionDatabaseName() { using (Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { return(db.Database.Connection.Database); } }
public int Delete(Kategori selectedKategori) { ReturnValue = 0; using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { try { Entities.Kategori findedKategori = db.Kategoriler.Find(selectedKategori.Id); if (findedKategori != null) { db.Kategoriler.Remove(findedKategori); ReturnValue = db.SaveChanges(); } else { throw new Exception("Silmek istediğiniz kayıt database içerisinde bulunamadı."); } } catch (Exception exception) { throw exception; } } return(ReturnValue); }
public string ConnectionStringInfo() { using (Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { return(db.Database.Connection.ConnectionString); } }
public List <Gelir> GetAll() { using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { return(db.Gelirler.ToList()); } }
public List <Kategori> GetAll() { using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { return(db.Kategoriler.ToList()); } }
public int Add(Gelir Entity) { using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { db.Gelirler.Add(Entity); ReturnValue = db.SaveChanges(); } return(ReturnValue); }
public int Delete(Gelir Entity) { using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { var result = db.Gelirler.Where(I => I.Id == Entity.Id).FirstOrDefault(); if (result != null) { db.Gelirler.Remove(result); ReturnValue = db.SaveChanges(); } } return(ReturnValue); }
public int Delete(Gider gider) { using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { var Entity = db.Giderler.Where(I => I.Id == gider.Id).FirstOrDefault(); if (Entity != null) { db.Giderler.Remove(Entity); ReturnValue = db.SaveChanges(); } } return(ReturnValue); }
public int Update(AltKategori updatedAltKategori) { ReturnValue = 0; using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { var entity = db.AltKategoriler.Where(I => I.Id == updatedAltKategori.Id).FirstOrDefault(); if (entity != null) { entity.SubKategoriAdi = updatedAltKategori.SubKategoriAdi; ReturnValue = db.SaveChanges(); } } return(ReturnValue); }
public int Delete(AltKategori selectedAltKategori) { ReturnValue = 0; using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { var entity = db.AltKategoriler.Where(I => I.Id == selectedAltKategori.Id).FirstOrDefault(); if (entity != null) { db.AltKategoriler.Remove(entity); ReturnValue = db.SaveChanges(); } } return(ReturnValue); }
public int Add(AltKategori newAltKategori) { try { using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { db.AltKategoriler.Add(newAltKategori); return(db.SaveChanges()); } } catch (Exception) { throw new Exception("Aynı isimde kayıt mevcut"); } }
public int Update(Gelir gelir) { ReturnValue = 0; using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { var result = db.Gelirler.Where(I => I.Id == gelir.Id).FirstOrDefault(); if (result != null) { result.KategoriAdi = gelir.KategoriAdi; result.KayitTarihi = gelir.KayitTarihi; result.Tutar = gelir.Tutar; result.AltKategoriAdi = gelir.AltKategoriAdi; result.Aciklama = gelir.Aciklama; ReturnValue = db.SaveChanges(); } } return(ReturnValue); }
public int Update(Kategori updatedKategori) { ReturnValue = 0; using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { try { Entities.Kategori findedKategori = db.Kategoriler.Find(updatedKategori.Id); if (findedKategori != null) { findedKategori.KategoriAdi = updatedKategori.KategoriAdi; } ReturnValue = db.SaveChanges(); } catch (Exception exception) { throw exception; } } return(ReturnValue); }
public int Add(Kategori newKategori) { ReturnValue = 0; using (Hesabım.Context.HesabimDatabaseContext db = new Context.HesabimDatabaseContext()) { try { db.Kategoriler.Add(newKategori); ReturnValue = db.SaveChanges(); } catch (System.Data.Entity.Infrastructure.DbUpdateException) { throw new Exception("Aynı isimde kayıt mevcuttur."); } catch (Exception exception) { throw exception; } } return(ReturnValue); }