using HighWayIot.Log4net; using HighWayIot.Repository.domain; using Models; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; namespace HighWayIot.Repository.service { public class ZxRecipeService { private static readonly Lazy lazy = new Lazy(() => new ZxRecipeService()); public static ZxRecipeService Instance { get { return lazy.Value; } } private LogHelper log = LogHelper.Instance; Repository _repository => new Repository("sqlserver"); /// /// 查询配方信息 /// /// public List GetRecipeInfos() { try { List entity = _repository.GetList(x => x.IsDeleted == false); return entity; } catch (Exception ex) { log.Error("配方信息获取异常", ex); return null; } } /// /// 根据配方编号查询配方信息 /// /// 配方编号 /// public List GetRecipeInfosByRecipeCode(string recipeCode) { try { List entity = _repository.GetList(x => x.IsDeleted == false && x.RecipeCode == recipeCode); return entity; } catch (Exception ex) { log.Error("根据编号查询配方信息获取异常", ex); return null; } } /// /// 修改配方信息 /// /// /// public bool UpdateRecipeInfo(ZxRecipeEntity recipeEntity) { try { return _repository.Update(recipeEntity); } catch(Exception ex) { log.Error("配方信息修改异常", ex); return false; } } /// /// 新增配方信息 /// /// /// public bool InsertRecipeInfo(ZxRecipeEntity recipeEntity) { try { return _repository.Insert(recipeEntity); } catch (Exception ex) { log.Error("配方信息添加异常", ex); return false; } } /// /// 删除配方信息 /// /// /// public bool DeleteRecipeInfoById(int id) { try { ZxRecipeEntity e = _repository.GetById(id); e.IsDeleted = true; return _repository.Update(e); } catch (Exception ex) { log.Error("配方信息删除异常", ex); return false; } } } }