Пример #1
0
        /// <summary>
        /// 增加路段信息
        /// </summary>
        /// <param name="inputDtos"></param>
        /// <returns></returns>
        public async Task <OperationResult> Add(params RoadInfoInputDto[] inputDtos)
        {
            inputDtos.CheckNotNull("inputDtos");
            foreach (var dtoData in inputDtos)
            {
                if (string.IsNullOrEmpty(dtoData.RoadNo))
                {
                    return(new OperationResult(OperationResultType.Error, "请正确填写路段编号,该组数据不被存储。"));
                }
                if (string.IsNullOrEmpty(dtoData.RoadName))
                {
                    return(new OperationResult(OperationResultType.Error, "请正确填写路段名称,该组数据不被存储。"));
                }
                if (RoadInfoRepository.CheckExists(x => x.RoadNo == dtoData.RoadNo))
                {
                    return(new OperationResult(OperationResultType.Error, $"路段编号 {dtoData.RoadNo} 的数据已存在,该组数据不被存储。"));
                }
                if (RoadInfoRepository.CheckExists(x => x.RoadName == dtoData.RoadName))
                {
                    return(new OperationResult(OperationResultType.Error, $"路段名称 {dtoData.RoadName} 的数据已存在,该组数据不被存储。"));
                }
                dtoData.StartMarkPointInfo = MarkPointInfoRepository.GetByKey(dtoData.StartMarkPointInfo_Id);
                if (Equals(dtoData.StartMarkPointInfo, null))
                {
                    return(new OperationResult(OperationResultType.Error, $"对应的开始地标点不存在,该组数据不被存储。"));
                }
                dtoData.EndMarkPointInfo = MarkPointInfoRepository.GetByKey(dtoData.EndMarkPointInfo_Id);
                if (Equals(dtoData.EndMarkPointInfo, null))
                {
                    return(new OperationResult(OperationResultType.Error, $"对应的结束地标点不存在,该组数据不被存储。"));
                }
            }
            RoadInfoRepository.UnitOfWork.BeginTransaction();
            var result = await RoadInfoRepository.InsertAsync(inputDtos);

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