private ProductPricingTierDTO Map(tblPricingTier tbl)
 {
     var dto = new ProductPricingTierDTO
                   {
                       MasterId = tbl.id,
                       DateCreated = tbl.IM_DateCreated,
                       DateLastUpdated = tbl.IM_DateLastUpdated,
                       StatusId = tbl.IM_Status,
                       Name = tbl.Name,
                       Code = tbl.Code,
                       Description = tbl.Description
                   };
     return dto;
 }
        private async Task<ImportValidationResultInfo> MapAndValidate(ProductPricingTierDTO dto, int index)
        {
            return await Task.Run(() =>
            {
                var entity = _mappingService.Map(dto);
                var exist = _ctx.tblPricingTier.FirstOrDefault(p => p.Code.ToLower() == dto.Code.ToLower() || 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.Code),
                    Entity = entity
                };
                return vResult;

            });


        }
Пример #3
0
 public ProductPricingTier Map(ProductPricingTierDTO dto)
 {
     if (dto == null) return null;
     var pricingTier = Mapper.Map<ProductPricingTierDTO, ProductPricingTier>(dto);
     return pricingTier;
 }