Exemplo n.º 1
0
 public void DeleteMaterial(List<int> ids)
 {
     using (var dbContext = new BasedataDbContext())
     {
         dbContext.Materials.Where(u => ids.Contains(u.ID)).Delete();
     }
 }
Exemplo n.º 2
0
 public Material GetMaterial(int id)
 {
     using (var dbContext = new BasedataDbContext())
     {
         return dbContext.Find<Material>(id);
     }
 }
Exemplo n.º 3
0
        public IEnumerable<Material> GetMaterialList(MaterialRequest request = null)
        {
            request = request ?? new MaterialRequest();
            using (var dbContext = new BasedataDbContext())
            {
                IQueryable<Material> materials = dbContext.Materials;
                if (!string.IsNullOrEmpty(request.MaterialName))
                    materials = materials.Where(u => u.MaterialName.Contains(request.MaterialName));

                return materials.OrderByDescending(u => u.ID).ToPagedList(request.PageIndex, request.PageSize);
            }
        }
Exemplo n.º 4
0
        public void SaveMaterial(Material material)
        {
            using (var dbContext = new BasedataDbContext())
            {

                if (material.ID > 0)
                {
                    dbContext.Update<Material>(material);
                }
                else
                {
                    dbContext.Insert<Material>(material);
                }
            }
        }