public void Update(Product product) { using (var db = new TruckSaleDb()) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); } }
public void Update(User user) { using (var db = new TruckSaleDb()) { db.Entry(user).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public void Save(Product product) { using (var db = new TruckSaleDb()) { db.Products.Add(product); db.SaveChanges(); } }
public ProductResource Add(ProductResource resource) { using (var db = new TruckSaleDb()) { db.ProductResources.Add(resource); db.SaveChanges(); } return(resource); }
public IList <Product> GetProductsByGroup(long id) { IList <Product> result = new List <Product>(); using (var db = new TruckSaleDb()) { result = db.Products.Where(p => p.ProductGroupId == id).ToList(); } return(result); }
public IList <ProductGroup> FindAllProducts() { IList <ProductGroup> result = new List <ProductGroup>(); using (TruckSaleDb db = new TruckSaleDb()) { result = db.Productgroups.ToList(); } return(result); }
public IList <ProductResource> GetByProduct(long productId) { IList <ProductResource> result = new List <ProductResource>(); using (var db = new TruckSaleDb()) { result = db.ProductResources.Where(r => r.productId == productId).ToList(); } return(result); }
public Product GetProduct(long id) { Product result = null; using (var db = new TruckSaleDb()) { result = db.Products.Include("ProductGroup").Single(p => p.Id == id); } return(result); }
public IList <Product> GetAllProducts() { IList <Product> result = new List <Product>(); using (var db = new TruckSaleDb()) { result = db.Products.Include("ProductGroup").ToList(); } return(result); }
public ProductGroup Get(long id) { ProductGroup group = null; using (TruckSaleDb db = new TruckSaleDb()) { group = db.Productgroups.Single(p => p.Id == id); } return(group); }
public ProductResource Remove(long id) { ProductResource result = null; using (var db = new TruckSaleDb()) { var product = db.ProductResources.Single(r => r.Id == id); result = db.ProductResources.Remove(product); db.SaveChanges(); } return(result); }
public Product Delete(long id) { Product result = null; using (var db = new TruckSaleDb()) { var product = db.Products.Single(p => p.Id == id); result = db.Products.Remove(product); db.SaveChanges(); } return(result); }
public User GetUserByUserName(string userName) { User user = null; using (var db = new TruckSaleDb()) { var list = db.Users.Where(u => u.UserName == userName).ToList(); if (list.Count > 0) { user = list[0]; } } return(user); }
public User Get(long id) { User user = null; using (var db = new TruckSaleDb()) { var list = db.Users.Where(u => u.Id == id).ToList(); if (list.Count > 0) { user = list[0]; } } return(user); }