Beispiel #1
0
 public Entities.Products AddProduct(Entities.Products product)
 {
     using (var context = new Models.SalesDBContext(Options))
     {
         context.Products.Add(product);
         context.SaveChanges();
     }
     return(product);
 }
Beispiel #2
0
        public Entities.Products GetProductByID(int ID)
        {
            Entities.Products product = null;

            using (var context = new Models.SalesDBContext(Options))
            {
                product = context.Products.FirstOrDefault(x => x.Id == ID);
            }
            return(product);
        }
Beispiel #3
0
        public List <Entities.Products> GetProducts()
        {
            List <Entities.Products> productsList = null;


            using (var context = new Models.SalesDBContext(Options))
            {
                productsList = context.Products.OrderBy(x => x.ProductName).ToList();
            }
            return(productsList);
        }
Beispiel #4
0
        public Entities.Products RemoveProduct(int ID)
        {
            Entities.Products product;

            using (var context = new Models.SalesDBContext(Options))
            {
                product = context.Products.FirstOrDefault(p => p.Id == ID);
                context.Products.Remove(product);
                context.SaveChanges();
            }

            return(product);
        }