public List <Product> findAll() { using (MyDemoEntities mde = new MyDemoEntities()) { return(mde.ProductEntities.Select(pe => new Product //DTO Nesnesine dönüştürüyoruz(Serileştirme hatası vermemesi için ara bir tipe dönüştürdük) { Id = pe.Id, Name = pe.Name, Price = pe.Price.Value, Quantity = pe.Quantity.Value }).ToList()); } }
public List <Product> findAll() { using (MyDemoEntities mde = new MyDemoEntities()) { return(mde.ProductEntities.Select(pe => new Product { Id = pe.Id, Name = pe.Name, Price = pe.Price.Value, Quantity = pe.Quantity.Value }).ToList()); } }
public Product find(string id) { using (MyDemoEntities mde = new MyDemoEntities()) { int nid = Convert.ToInt32(id); return(mde.ProductEntities.Where(pe => pe.Id == nid).Select(pe => new Product //DTO Nesnesine dönüştürüyoruz { Id = pe.Id, Name = pe.Name, Price = pe.Price.Value, Quantity = pe.Quantity.Value }).First()); } }
public Product find(string id) { using (MyDemoEntities mde = new MyDemoEntities()) { int nid = Convert.ToInt32(id); return(mde.ProductEntities.Where(p => p.Id == nid).Select(p => new Product { Id = p.Id, Name = p.Name, Price = p.Price.Value, Quantity = p.Quantity.Value }).First()); } }
public bool delete(Product product) { using (MyDemoEntities mde = new MyDemoEntities()) { try { int id = Convert.ToInt32(product.Id); ProductEntity pe = mde.ProductEntities.Single(p => p.Id == id); mde.ProductEntities.Remove(pe); mde.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }
public bool delete(Product product) { using (MyDemoEntities mde = new MyDemoEntities()) { try { int id = Convert.ToInt32(product.Id); ProductEntity pe = mde.ProductEntities.Single(p => p.Id == id); mde.ProductEntities.Remove(pe); mde.SaveChanges(); return true; } catch { return false; } } }
public bool edit(Product product) { using (MyDemoEntities mde = new MyDemoEntities()) { try { int id = Convert.ToInt32(product.Id); ProductEntity pe = mde.ProductEntities.Single(p => p.Id == id); pe.Name = product.Name; pe.Price = product.Price; pe.Quantity = product.Quantity; mde.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }
public bool create(Product product) { using (MyDemoEntities mde = new MyDemoEntities()) { try { ProductEntity pe = new ProductEntity(); pe.Name = product.Name; pe.Price = product.Price; pe.Quantity = product.Quantity; mde.ProductEntities.Add(pe); mde.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }
public bool edit(Product product) { using (MyDemoEntities mde = new MyDemoEntities()) { try { int id = Convert.ToInt32(product.Id); ProductEntity pe = mde.ProductEntities.Single(p => p.Id == id); pe.Name = product.Name; pe.Price = product.Price; pe.Quantity = product.Quantity; mde.SaveChanges(); return true; } catch { return false; } } }
public bool create(Product product) { using (MyDemoEntities mde = new MyDemoEntities()) { try { ProductEntity pe = new ProductEntity(); pe.Name = product.Name; pe.Price = product.Price; pe.Quantity = product.Quantity; mde.ProductEntities.Add(pe); mde.SaveChanges(); return true; } catch { return false; } } }
public Product find(string id) { using (MyDemoEntities mde = new MyDemoEntities()) { int nid = Convert.ToInt32(id); return mde.ProductEntities.Where(pe => pe.Id == nid).Select(pe => new Product { Id = pe.Id, Name = pe.Name, Price = pe.Price.Value, Quantity = pe.Quantity.Value }).First(); } }
public List<Product> findAll() { using (MyDemoEntities mde = new MyDemoEntities()) { return mde.ProductEntities.Select(pe => new Product { Id = pe.Id, Name = pe.Name, Price = pe.Price.Value, Quantity = pe.Quantity.Value }).ToList(); } }