Exemple #1
0
        public virtual async Task Add <T>(T currentData) where T : class
        {
            try
            {
                await _context.Set <T>().AddAsync(currentData);

                await _context.SaveChangesAsync();
            } catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #2
0
 public Tablo GetById(int id)
 {
     using (var context = new ToDoContext())
     {
         return(context.Set <Tablo>().Find(id));
     }
 }
Exemple #3
0
 public void Guncelle(Tablo tablo)
 {
     //Güncelleme işlemi gerçekleştiğinde state'in değişeceğini bildirdik.
     using var context = new ToDoContext();
     context.Set <Tablo>().Update(tablo);
     context.SaveChanges();
 }
Exemple #4
0
        public void Update(Table table)
        {
            using var context = new ToDoContext();
            context.Set <Table>().Update(table);

            context.SaveChanges();
        }
Exemple #5
0
 public List <Tablo> GetAll()
 {
     using (var context = new ToDoContext())
     {
         return(context.Set <Tablo>().ToList());
     }
 }
 public void Kaydet(Tablo tablo)
 {
     using (var context = new ToDoContext())
     {
         context.Set <Tablo>().Add(tablo);
         context.SaveChanges();
     }
 }
 public void Sil(Tablo tablo)
 {
     using (var context = new ToDoContext())
     {
         context.Set <Tablo>().Remove(tablo);
         context.SaveChanges();
     }
 }
 public void Guncelle(Tablo tablo)
 {
     using (var context = new ToDoContext())
     {
         context.Set <Tablo>().Update(tablo);
         context.SaveChanges();
     }
 }
Exemple #9
0
        private void SeedZadania(ToDoContext context)
        {
            var idUzytkownika = context.Set <Uzytkownik>().Where(u => u.UserName == "*****@*****.**").FirstOrDefault().Id;

            for (int i = 1; i <= 5; i++)
            {
                var zad = new Zadanie()
                {
                    Id     = i,
                    Nazwa  = "Zadanie" + i.ToString(),
                    Opis   = "Opis zadania" + i.ToString(),
                    Termin = DateTime.Now.AddDays(-i),
                    Status = (((i % 2 + 2) % 2 == 0) ? true : false)
                };
                context.Set <Zadanie>().AddOrUpdate(zad);
            }
            context.SaveChanges();
        }
        public List <T> GetItems(Expression <Func <T, bool> > predicate, params string[] navigationProperties)
        {
            List <T> list;
            var      query = _context.Set <T>().AsQueryable();

            foreach (string navigationProperty in navigationProperties)
            {
                query = query.Include(navigationProperty);//got to reaffect it.
            }
            list = query.Where(predicate).ToList <T>();
            return(list);
        }
Exemple #11
0
 private void SeedZamowienia(ToDoContext context)
 {
     for (int i = 1; i <= 3; i++)
     {
         var zam = new Zamowienie()
         {
             ZamowienieID   = i,
             KlientID       = i,
             DataZamowienia = DateTime.Now.AddDays(-i),
             CenaZamowienia = 1000 * i
         };
         context.Set <Zamowienie>().AddOrUpdate(zam);
     }
     context.SaveChanges();
 }
Exemple #12
0
 private void SeedKlienci(ToDoContext context)
 {
     for (int i = 1; i <= 5; i++)
     {
         var klient = new Klient()
         {
             KlientID      = i,
             Nazwa         = "darek" + i.ToString(),
             Addres        = "Lodz_" + i.ToString(),
             Komorka       = "12345678" + i.ToString(),
             DataUrodzenia = DateTime.Now.AddDays(-i - 40),
             EmailID       = "darek" + i.ToString() + "@o2.pl"
         };
         context.Set <Klient>().AddOrUpdate(klient);
     }
     context.SaveChanges();
 }
Exemple #13
0
        public CrudState Update(T entity)
        {
            T old = context.Set <T>().Find(entity.Id);

            if (old != null)
            {
                try
                {
                    entity.UpdateAt = DateTime.Now;
                    //context.Entry(old).CurrentValues.SetValues(entity);
                    return(Save() == ConnectionState.Success ? CrudState.Success : CrudState.ConnectionError);
                }
                catch (Exception)
                {
                    return(CrudState.EntityError);
                }
            }
            else
            {
                return(CrudState.NotFound);
            }
        }
Exemple #14
0
 /// <summary>
 /// Public constructor to inject dependancies into the repository
 /// </summary>
 /// <param name="context">EF context to inject</param>
 public RDBERepository(ToDoContext context)
 {
     this.Context = context;
     this.DbSet   = context.Set <T>();
 }
Exemple #15
0
 public BaseController(ToDoContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
     _DbSet   = _context.Set <T>();
 }
Exemple #16
0
 public Repository(ToDoContext context)
 {
     this.context = context;
     dbset        = context.Set <T>();
 }
Exemple #17
0
 public BaseRepository()
 {
     context = new ToDoContext();
     dbSet   = context.Set <T>();
 }
Exemple #18
0
 public Tablo GetirIdile(int id)
 {
     using var context = new ToDoContext();
     return(context.Set <Tablo>().Find(id));
 }
 public Table GetWithId(int id)
 {
     using var context = new ToDoContext();
     return(context.Set <Table>().Find(id));
 }
 public List <Table> GetAll()
 {
     using var context = new ToDoContext();
     return(context.Set <Table>().ToList());
 }
 public void Delete(Table table)
 {
     using var context = new ToDoContext();
     context.Set <Table>().Remove(table);
     context.SaveChanges();
 }
Exemple #22
0
 public List <Tablo> GetirHepsi()
 {
     //using keywordu parametre aldığı kaynak(burda context) tükendiği zaman içerisindeki kodları garbage collactora gönderir.
     using var context = new ToDoContext();
     return(context.Set <Tablo>().ToList());
 }
Exemple #23
0
 public List <TEntity> DajSveEntitete()
 {
     return(_context.Set <TEntity>().ToList());
 }
Exemple #24
0
 public Tablo GetirIdile(int id)
 {
     // context tükendiğinde bize id değerini getirmesini istedik.
     using var context = new ToDoContext();
     return(context.Set <Tablo>().Find(id));
 }
 public GenericRepository(ToDoContext _context)
 {
     this._context = _context;
     table         = _context.Set <T>();
 }
Exemple #26
0
 public Repository()
 {
     _context = new ToDoContext();
     _dbSet   = _context.Set <Task>();
 }
Exemple #27
0
 public List <Tablo> GetirHepsi()
 {
     using var context = new ToDoContext();
     return(context.Set <Tablo>().ToList());
 }