private ProductInfoResponse IsR(ProductInfoResponse response, UserModel currentAuthUser, int productId) { if (response == null || currentAuthUser == null) { return response; } //是否收藏 var favoriteEntity = _favoriteService.Get(currentAuthUser.Id, productId, SourceType.Product); if (favoriteEntity != null) { response.CurrentUserIsFavorited = true; } //是否获取过优惠码 var list = _couponService.Get(currentAuthUser.Id, productId, SourceType.Product); if (list != null && list.Count > 0) { response.CurrentUserIsReceived = true; } return response; }
private static ItemsInfoResponse ItemsInfoResponseMapping(ProductInfoResponse productInfoResponse) { var target = Mapper.Map<ProductInfoResponse, ItemsInfoResponse>(productInfoResponse); target.SType = SourceType.Product; target.Store = productInfoResponse.StoreInfoResponse; target.Resources = productInfoResponse.ResourceInfoResponses; target.Promotions = productInfoResponse.Promotions; return target; }
public static CouponCodeResponse CouponCodeResponseMapping(CouponHistoryEntity source, ProductInfoResponse product, PromotionInfoResponse promotion) { if (source == null) { return null; } var target = Mapper.Map<CouponHistoryEntity, CouponCodeResponse>(source); var productname = String.Empty; var producttype = 0; var productid = 0; var productDescription = String.Empty; if (promotion != null) { productname = promotion.Name; producttype = (int)SourceType.Promotion; productid = promotion.Id; productDescription = promotion.Description; } else { if (product != null) { productname = product.Name; producttype = (int)SourceType.Product; productid = product.Id; productDescription = product.Description; } } target.ProductId = productid; target.ProductName = productname; target.ProductType = producttype; target.ProductDescription = productDescription; return target; }