Exemplo n.º 1
0
 public IEnumerable <T> GetById(int id)
 {
     using (var entity = new ModelDataEntities2())
     {
         return(entity.Set <T>().Where(x => x.Id == id).ToList());
     }
 }
Exemplo n.º 2
0
 public Product GetByTitle(string title)
 {
     using (var entity = new ModelDataEntities2())
     {
         return(entity.Product.FirstOrDefault(m => m.ProductName == title));
     }
 }
Exemplo n.º 3
0
 public IEnumerable <SaleInfo> GetSalesByManagerId(int id)
 {
     using (var context = new ModelDataEntities2())
     {
         return(context.Manager.FirstOrDefault(m => m.Id == id).SaleInfo.ToList());
     }
 }
Exemplo n.º 4
0
 public decimal GetSumById(int id)
 {
     using (var context = new ModelDataEntities2())
     {
         return(context.Manager.FirstOrDefault(m => m.Id == id).SaleInfo.Sum(x => x.Sum));
     }
 }
Exemplo n.º 5
0
 public Manager GetByName(string name)
 {
     using (var entity = new ModelDataEntities2())
     {
         return(entity.Manager.FirstOrDefault(m => m.ManagerName == name));
     }
 }
Exemplo n.º 6
0
 public Client GetByName(string name)
 {
     using (var entity = new ModelDataEntities2())
     {
         return(entity.Client.FirstOrDefault(m => m.ClientName == name));
     }
 }
Exemplo n.º 7
0
 public void Update(T item)
 {
     using (var context = new ModelDataEntities2())
     {
         context.Entry(item).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public IEnumerable <T> GetAll()
 {
     using (var context = new ModelDataEntities2())
     {
         var entity = context.Set <T>().ToList();
         return(entity);
     }
 }
Exemplo n.º 9
0
 public int Insert(T item)
 {
     using (var context = new ModelDataEntities2())
     {
         var entity = context.Set <T>().Add(item);
         context.SaveChanges();
         return(item.Id);
     }
 }