Пример #1
0
        /// <summary>
        /// 更新供应商信息
        /// </summary>
        /// <param name="inputDtos"></param>
        /// <returns></returns>
        public async Task <OperationResult> Update(params MatSupplierInfoInputDto[] inputDtos)
        {
            inputDtos.CheckNotNull("inputDtos");
            //
            foreach (MatSupplierInfoInputDto dtoData in inputDtos)
            {
                if (string.IsNullOrEmpty(dtoData.SupplierCode))
                {
                    return(new OperationResult(OperationResultType.Error, "请正确填写供应商编号,该组数据不被存储。"));
                }
                if (string.IsNullOrEmpty(dtoData.SupplierName))
                {
                    return(new OperationResult(OperationResultType.Error, "请正确填写供应商名称,该组数据不被存储。"));
                }
                //
                if (MatSupplierRepository.CheckExists(x => x.SupplierCode == dtoData.SupplierCode && x.Id != dtoData.Id))
                {
                    return(new OperationResult(OperationResultType.Error, $"供应商编号 {dtoData.SupplierCode} 的数据已存在,该组数据不被存储。"));
                }
                if (MatSupplierRepository.CheckExists(x => x.SupplierName == dtoData.SupplierName && x.Id != dtoData.Id))
                {
                    return(new OperationResult(OperationResultType.Error, $"供应商名称 {dtoData.SupplierName} 的数据已存在,该组数据不被存储。"));
                }
            }
            //
            MatSupplierRepository.UnitOfWork.BeginTransaction();
            var result = await MatSupplierRepository.UpdateAsync(inputDtos);

            MatSupplierRepository.UnitOfWork.Commit();
            return(result);
        }
Пример #2
0
 /// <summary>
 /// 检查实体是否存在
 /// </summary>
 /// <param name="predicate"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool CheckExists(Expression <Func <MatSupplierInfo, bool> > predicate, Guid id)
 {
     return(MatSupplierRepository.CheckExists(predicate, id));
 }