private async Task<ImportValidationResultInfo> MapAndValidate(TerritoryDTO dto,int index) { return await Task.Run(() => { if (dto == null) return null; var territory = _mappingService.Map(dto); var exist = _existingteritories.FirstOrDefault( p => p.Name.ToLower() == territory.Name.ToLower()); territory.Id = exist == null ? Guid.NewGuid() : exist.Id; var res = _territoryRepository.Validate(territory); var vResult = new ImportValidationResultInfo() { Results = res.Results, Description = string.Format("Row-{0} code or name=>{1}", index, territory.Name), Entity =territory }; return vResult; }); }
private TerritoryDTO Map(tblTerritory tbl) { var dto = new TerritoryDTO(); dto.MasterId = tbl.id; dto.DateCreated = tbl.IM_DateCreated; dto.DateLastUpdated = tbl.IM_DateLastUpdated; dto.StatusId = tbl.IM_Status; dto.Name = tbl.Name; return dto; }
public Territory Map(TerritoryDTO dto) { if (dto == null) return null; var territory = Mapper.Map<TerritoryDTO, Territory>(dto); return territory; }