|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Models
|
|
|
|
|
{
|
|
|
|
|
public class ProductProvider : IProvider<Product>
|
|
|
|
|
{
|
|
|
|
|
private readonly TicketEntities db = new TicketEntities();
|
|
|
|
|
public int Delete(Product t)//删除
|
|
|
|
|
{
|
|
|
|
|
if (t == null) return 0;
|
|
|
|
|
var model = db.Product.ToList().FirstOrDefault(item => t.ProductCode == item.ProductCode);
|
|
|
|
|
if (model == null) return 0;
|
|
|
|
|
db.Product.Remove(model);
|
|
|
|
|
int count = db.SaveChanges();
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Insert(Product t)//插入
|
|
|
|
|
{
|
|
|
|
|
if (t == null) return 0;
|
|
|
|
|
if (String.IsNullOrEmpty(t.ProductCode)) return 0;
|
|
|
|
|
db.Product.Add(t);
|
|
|
|
|
int counti = db.SaveChanges();
|
|
|
|
|
return counti;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Product> Select()
|
|
|
|
|
{
|
|
|
|
|
return db.Product.SqlQuery("select * from Product").ToList();//查询
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Product> Selects0()
|
|
|
|
|
{
|
|
|
|
|
return db.Product.SqlQuery("select * from Product where ProductType = 0").ToList();//查询
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Product> Selects1()
|
|
|
|
|
{
|
|
|
|
|
return db.Product.SqlQuery("select * from Product where ProductType = 1").ToList();//查询
|
|
|
|
|
}
|
|
|
|
|
public List<Product> Selects2()
|
|
|
|
|
{
|
|
|
|
|
return db.Product.SqlQuery("select * from Product where ProductType = 2").ToList();//查询
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Product> Selectsql(Product t)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
public int Update(Product t)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|