示例#1
0
 public void Update(Product product)
 {
     using (var db = new TruckSaleDb())
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
示例#2
0
 public void Update(User user)
 {
     using (var db = new TruckSaleDb())
     {
         db.Entry(user).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
示例#3
0
 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);
 }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        public IList <Product> GetAllProducts()
        {
            IList <Product> result = new List <Product>();

            using (var db = new TruckSaleDb())
            {
                result = db.Products.Include("ProductGroup").ToList();
            }

            return(result);
        }
示例#10
0
        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);
        }
示例#12
0
        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);
        }
示例#13
0
        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);
        }
示例#14
0
        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);
        }