Exemple #1
0
        private async Task <List <VendorModel> > PrepareVendorAll(GetVendorAll request)
        {
            var model = new List <VendorModel>();

            var vendors = await _vendorService.GetAllVendors();

            foreach (var vendor in vendors)
            {
                var vendorModel = new VendorModel
                {
                    Id              = vendor.Id,
                    Name            = vendor.GetTranslation(x => x.Name, request.Language.Id),
                    Description     = vendor.GetTranslation(x => x.Description, request.Language.Id),
                    MetaKeywords    = vendor.GetTranslation(x => x.MetaKeywords, request.Language.Id),
                    MetaDescription = vendor.GetTranslation(x => x.MetaDescription, request.Language.Id),
                    MetaTitle       = vendor.GetTranslation(x => x.MetaTitle, request.Language.Id),
                    SeName          = vendor.GetSeName(request.Language.Id),
                    AllowCustomersToContactVendors = _vendorSettings.AllowCustomersToContactVendors,
                    UserFields = vendor.UserFields
                };

                //prepare vendor address
                vendorModel.Address = await _mediator.Send(new GetVendorAddress()
                {
                    Language          = request.Language,
                    Address           = vendor.Address,
                    ExcludeProperties = false,
                });

                //prepare picture model
                var pictureModel = new PictureModel
                {
                    Id = vendor.PictureId,
                    FullSizeImageUrl = await _pictureService.GetPictureUrl(vendor.PictureId),
                    ImageUrl         = await _pictureService.GetPictureUrl(vendor.PictureId, _mediaSettings.VendorThumbPictureSize),
                    Title            = string.Format(_translationService.GetResource("Media.Vendor.ImageLinkTitleFormat"), vendorModel.Name),
                    AlternateText    = string.Format(_translationService.GetResource("Media.Vendor.ImageAlternateTextFormat"), vendorModel.Name)
                };
                vendorModel.PictureModel = pictureModel;
                model.Add(vendorModel);
            }

            return(model);
        }
 public async Task <IList <VendorModel> > Handle(GetVendorAll request, CancellationToken cancellationToken)
 {
     return(await _cacheManager.GetAsync(ModelCacheEventConst.VENDOR_ALL_MODEL_KEY, () => PrepareVendorAll(request)));
 }