/// <summary>
        /// 增加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <Result <MaterialInfo> > addAsync(MaterialInfo model)
        {
            Result <MaterialInfo> result    = new Result <MaterialInfo>();
            MaterialInfoQuery     condition = new MaterialInfoQuery()
            {
                materialName = model.materialName, mat_size = model.mat_size
            };
            var isExist = dao.searchCountByCondition(condition);

            if (isExist > 0)
            {
                result.addError("产品已存在");
            }
            else
            {
                model.findIndx = BeanHelper.getFistCharUpper(model.materialName);
                var resultDAO = await dao.add(model);

                if (!resultDAO.success)
                {
                    result.addError(resultDAO.message);
                }
            }
            return(result);
        }
        public JsonResult list(MaterialInfoQuery condition)
        {
            ViewBag.condition = condition;
            Pager <List <MaterialInfo> > pager = new Pager <List <MaterialInfo> >();

            pager = service.searchByCondition(pager, condition);
            JsonResult result = Json(pager.data);

            return(result);
        }
Exemplo n.º 3
0
        public List <MaterialInfo> searchListByCondition(MaterialInfoQuery t)
        {
            LayerDbContext context = new LayerDbContext();
            var            result  = context.materialInfos.Where(x => x.id > 0);

            result = string.IsNullOrEmpty(t.material) ? result : result.Where(x => x.material == (t.material));
            result = string.IsNullOrEmpty(t.materialName) ? result : result.Where(x => x.materialName == (t.materialName));
            result = string.IsNullOrEmpty(t.mat_color) ? result : result.Where(x => x.mat_color == t.mat_color);
            result = string.IsNullOrEmpty(t.mat_size) ? result : result.Where(x => x.mat_size == t.mat_size);
            result = string.IsNullOrEmpty(t.mat_type) ? result : result.Where(x => x.mat_type == t.mat_type);
            result = string.IsNullOrEmpty(t.alias) ? result : result.Where(x => x.alias == (t.alias));
            result = string.IsNullOrEmpty(t.remark) ? result : result.Where(x => x.remark.Contains(t.remark));
            return(result.ToList());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据条件查询
        /// </summary>
        /// <param name="pager"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        public List <MaterialInfo> searchByCondition(Pager <List <MaterialInfo> > pager, MaterialInfoQuery t)
        {
            LayerDbContext context = new LayerDbContext();
            int            start   = (pager.page - 1) * pager.recPerPage;
            var            result  = context.materialInfos.Where(x => x.id > 0);

            result = string.IsNullOrEmpty(t.material) ? result : result.Where(x => x.material == (t.material));
            result = string.IsNullOrEmpty(t.materialName) ? result : result.Where(x => x.materialName == (t.materialName));
            result = string.IsNullOrEmpty(t.mat_color) ? result : result.Where(x => x.mat_color == t.mat_color);
            result = string.IsNullOrEmpty(t.mat_size) ? result : result.Where(x => x.mat_size == t.mat_size);
            result = string.IsNullOrEmpty(t.mat_type) ? result : result.Where(x => x.mat_type == t.mat_type);
            result = string.IsNullOrEmpty(t.alias) ? result : result.Where(x => x.alias == (t.alias));
            result = string.IsNullOrEmpty(t.remark) ? result : result.Where(x => x.remark.Contains(t.remark));
            result = result.OrderBy(x => x.material);
            result = result.Skip(start).Take(pager.recPerPage);
            return(result.ToList());
        }
        /// <summary>
        /// 根据条件查询
        /// </summary>
        /// <param name="pager"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public Pager <List <MaterialInfo> > searchByCondition(Pager <List <MaterialInfo> > pager, MaterialInfoQuery condition)
        {
            Task <List <MaterialInfo> > task = Task.Factory.StartNew(() => dao.searchByCondition(pager, condition));

            pager.data = task.Result;
            Task <int> countTask = Task.Factory.StartNew(() => dao.searchCountByCondition(condition));

            pager.recTotal = countTask.Result;
            return(pager);
        }
        public async Task <List <MaterialInfo> > searchListByCondition(MaterialInfoQuery condition)
        {
            Task <List <MaterialInfo> > result = Task.Factory.StartNew(() => dao.searchListByCondition(condition));

            return(await result);
        }
 // GET: MaterialInfo
 public ActionResult Index(Pager <List <MaterialInfo> > pager, MaterialInfoQuery condition)
 {
     ViewBag.condition = condition;
     pager             = service.searchByCondition(pager, condition);
     return(View(pager));
 }