コード例 #1
0
        private async Task<ImportValidationResultInfo> MapAndValidate(AssetCategoryDTO dto, int index)
        {
            return await Task.Run(() =>
            {
                if (dto == null) return null;
                var entity = _mappingService.Map(dto);
                var exist = _ctx.tblAssetCategory.FirstOrDefault(p => p.Name.ToLower() == dto.Name.ToLower());

                entity.Id = exist == null ? Guid.NewGuid() : exist.Id;

                var res = _repository.Validate(entity);
                var vResult = new ImportValidationResultInfo()
                {
                    Results = res.Results,
                    Description =
                        string.Format("Row-{0} name or code=>{1}", index,
                                      entity.Name ?? entity.Description),
                    Entity = entity
                };
                return vResult;

            });


        }
コード例 #2
0
 public AssetCategory Map(AssetCategoryDTO dto)
 {
     if (dto == null) return null;
     var assetCategory = Mapper.Map<AssetCategoryDTO, AssetCategory>(dto);
     assetCategory.AssetType = _assetTypeRepository.GetById(dto.AssetTypeMasterId);
     return assetCategory;
 }