123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using DbCommon.BusinessCore.DbCore;
- using DbCommon.Enties.DbModels;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DbCommon.BusinessCore.BaseCore
- {
- public class FmsStockManager : FmsDbContext<FmsStock>
- {
- public void Init()
- {
- //If no exist create datebase
- //Db.DbMaintenance.CreateDatabase();
- if (!Db.DbMaintenance.IsAnyTable("barcodesforagv"))
- {
- //Create tables
- Db.CodeFirst.InitTables(typeof(FmsStock));
- }
- }
- public int CountMaterial(string material)
- {
- return Db.Queryable<FmsStock>()
- .Where(d => d.StockCode == material && d.Flag == 0)
- .Select(f => f.StockCode)
- .Count();
- }
- public bool UpdateFlag(string material)
- {
- return CurrentDb.Update(
- d => new FmsStock()
- {
- Flag = 1,
- },
- d => d.StockCode == material && d.Flag == 0);
- }
- public bool UpdateFlag(string[] materialArray)
- {
- return CurrentDb.Update(
- d => new FmsStock()
- {
- Flag = 1,
- },
- d => materialArray.Contains(d.StockCode) && d.Flag == 0);
- }
- public bool UpdateAllFlag()
- {
- return CurrentDb.Update(
- d => new FmsStock()
- {
- Flag = 1,
- },
- d => d.Flag == 0);
- }
- }
- }
|