예제 #1
0
        private async Task<ImportValidationResultInfo> MapAndValidate(DistrictDTO dto, int index)
        {
            return await Task.Run(() =>
            {
                if (dto == null) return null;
                var entity = _mappingService.Map(dto);
                var exist = _ctx.tblDistrict.FirstOrDefault(p => p.District.ToLower() == dto.DistrictName.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.DistrictName),
                    Entity = entity
                };
                return vResult;

            });


        }
예제 #2
0
 public District Map(DistrictDTO dto)
 {
     if (dto == null) return null;
     var district = Mapper.Map<DistrictDTO, District>(dto);
     district.Province = _provincesRepository.GetById(dto.ProvinceMasterId);
     return district;
 }