class product
This commit is contained in:
@@ -1,12 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using LuminousSales.Data;
|
||||
using LuminousSales.Data.Model;
|
||||
|
||||
namespace LuminousSales.Business
|
||||
{
|
||||
public class ProductBusiness
|
||||
{
|
||||
|
||||
private ProductContext productContext;
|
||||
|
||||
public List<Product> GetAll()
|
||||
{
|
||||
using (productContext = new ProductContext())
|
||||
{
|
||||
return productContext.Products.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public Product Get(int id)
|
||||
{
|
||||
using (productContext = new ProductContext())
|
||||
{
|
||||
return productContext.Products.Find(id);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(Product product)
|
||||
{
|
||||
using (productContext = new ProductContext())
|
||||
{
|
||||
productContext.Products.Add(product);
|
||||
productContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(Product product)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -6,5 +6,9 @@ namespace LuminousSales.Data.Model
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public int AmountInStock { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.Text;
|
||||
using LuminousSales.Data.Model;
|
||||
|
||||
namespace LuminousSales.Data
|
||||
{
|
||||
public class ProductContext
|
||||
public class ProductContext : DbContext
|
||||
{
|
||||
public ProductContext():base("name = ProductContext")
|
||||
{
|
||||
|
||||
}
|
||||
public DbSet<Product> Products { get; set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user