You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
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 int Update(Product t)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|
|
|