public async Task <GetVendorForViewDto> GetVendorForView(int?id) { // START UPDATE // Add this code to enable the Vendor Profile to work -- NB: made 'id' nullable and updated the Interface accordingly Vendor currentVendor; int vendorId; if (id == null) { currentVendor = _vendorRepository.GetAll().Where(e => e.TenantId == AbpSession.TenantId).FirstOrDefault(); if (currentVendor == null) { return(new GetVendorForViewDto()); } vendorId = currentVendor.Id; } else { vendorId = (int)id; } var vendor = await _vendorRepository.GetAsync(vendorId); // END UPDATE // var output = new GetVendorForViewDto { Vendor = ObjectMapper.Map <VendorDto>(vendor) }; if (output.Vendor.SsicCodeId != null) { var _lookupSsicCode = await _lookup_ssicCodeRepository.FirstOrDefaultAsync((int)output.Vendor.SsicCodeId); output.SsicCodeCode = _lookupSsicCode.Code.ToString(); } if (output.Vendor != null) { var _lookupCurrency = await _lookup_currencyRepository.FirstOrDefaultAsync((int)output.Vendor.CurrencyId); output.CurrencyCode = _lookupCurrency.Code.ToString(); } if (output.Vendor.LogoUrl != null) { int length = (output.Vendor.LogoUrl.Length >= 36) ? 36 : output.Vendor.LogoUrl.Length; output.Vendor.LogoUrl = string.Format("{0}...", output.Vendor.LogoUrl.Substring(0, length)); } if (output.Vendor.Website != null) { int length = (output.Vendor.Website.Length >= 36) ? 36 : output.Vendor.Website.Length; output.Vendor.Website = string.Format("{0}...", output.Vendor.Website.Substring(0, length)); } return(output); }
public async Task <GetVendorForViewDto> GetVendorForView(int id) { var vendor = await _vendorRepository.GetAsync(id); var output = new GetVendorForViewDto { Vendor = ObjectMapper.Map <VendorDto>(vendor) }; if (output.Vendor.VendorCategoryId != null) { var _lookupVendorCategory = await _lookup_vendorCategoryRepository.FirstOrDefaultAsync((int)output.Vendor.VendorCategoryId); output.VendorCategoryName = _lookupVendorCategory?.Name?.ToString(); } return(output); }