コード例 #1
0
        private async Task<ImportValidationResultInfo> MapAndValidate(OutletCategoryDTO dto, int index)
        {
            return await Task.Run(() =>
            {
                var entity = _mappingService.Map(dto);
                var exist = _ctx.tblOutletCategory.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.Code),
                    Entity = entity
                };
                return vResult;

            });


        }
コード例 #2
0
 public OutletCategory Map(OutletCategoryDTO dto)
 {
     if (dto == null) return null;
      OutletCategory outletCategory = Mapper.Map<OutletCategoryDTO, OutletCategory>(dto);
     return outletCategory;
 }