Example #1
0
        /// <summary>
        ///  Set the transfer objects. We create the transfer object from the entity.
        /// </summary>
        /// <param name="reader">GridReader reader of dapper results</param>
        /// <param name="clientPoco">Poco to check if there is a null parameter.</param>
        ///
        private void SetDataTransferObject(SqlMapper.GridReader reader, ClientDto clientPoco)
        {
            if (reader == null)
            {
                return;
            }
            while (!reader.IsConsumed)
            {
                var row = reader.Read().FirstOrDefault();
                if (row != null)
                {
                    var entity = MapSingleEntity(row);
                    if (entity != null)
                    {
                        var currentType = entity.Type as Type;
                        var dtoType     = entity.DtoType as Type;
                        var mappedDto   = MapperUtils.GetMappedValue(_mapper, entity.Value, currentType, dtoType);

                        if ((mappedDto != null) && (mappedDto.Count >= 0))
                        {
                            var currentValue = mappedDto[0];
                            if (clientPoco != null)
                            {
                                SetHelper(currentValue, dtoType);
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        ///  Set the transfer objects. We create the transfer object from the entity.
        /// </summary>
        /// <param name="reader">GridReader reader of dapper results</param>
        /// <param name="office">Poco to check if there is a null parameter.</param>
        private void SetDataTransferObject(SqlMapper.GridReader reader, SUBLICEN company, ref CompanyDto dto)
        {
            // think about the GridReader.

            if (reader == null)
            {
                return;
            }
            if (!string.IsNullOrEmpty(company.CP))
            {
                if (reader.IsConsumed)
                {
                    return;
                }
                Helper.CityDto = MapperUtils.GetMappedValue <POBLACIONES, CityDto>(reader.Read <POBLACIONES>().FirstOrDefault(), _mapper);
            }

            if (!string.IsNullOrEmpty(company.NACIO))
            {
                if (reader.IsConsumed)
                {
                    return;
                }

                Helper.CountryDto = MapperUtils.GetMappedValue <Country, CountryDto>(reader.Read <Country>().FirstOrDefault(), _mapper);
            }

            if (!string.IsNullOrEmpty(company.PROVINCIA))
            {
                if (reader.IsConsumed)
                {
                    return;
                }
                Helper.ProvinciaDto = MapperUtils.GetMappedValue <PROVINCIA, ProvinciaDto>(reader.Read <PROVINCIA>().FirstOrDefault(), _mapper);
            }
            var listOfOffices = reader.Read <OFICINAS>().ToList();

            dto.Offices = _mapper.Map <IEnumerable <OFICINAS>, IEnumerable <OfficeDtos> >(listOfOffices);
        }