public StoreEntity StoreEntityMapping(StoreModel source) { var target = Mapper.Map<StoreModel, StoreEntity>(source); return target; }
private static UserModel UserModelMapping(UserEntity source, StoreModel storeModel, List<UserAccountModel> userAccountModels, List<int> userRoles) { if (source == null) { return null; } var target = Mapper.Map<UserEntity, UserModel>(source); //这步可以判断 target.Store = storeModel; //modelAccount target.Accounts = userAccountModels; //roles target.UserRoles = userRoles; //favorcount //ilikecount //likemecount //LOGO if (!String.IsNullOrWhiteSpace(target.Logo)) { if (!target.Logo.StartsWith("http://", StringComparison.OrdinalIgnoreCase)) { target.Logo = ConfigManager.GetHttpApiImagePath() + target.Logo; } } if (target.Accounts == null || target.Accounts.Count == 0) { return target; } foreach (var item in target.Accounts) { switch (item.AType) { case AccountType.ConsumptionCount: target.ConsumptionCount = (int)item.Amount; break; case AccountType.Coupon: target.CouponCount = (int)item.Amount; break; case AccountType.FavorCount: target.FavorCount = (int)item.Amount; break; case AccountType.IlikeCount: target.ILikeCount = (int)item.Amount; break; case AccountType.LikeMeCount: target.LikeMeCount = (int)item.Amount; break; case AccountType.Point: target.PointCount = (int)item.Amount; break; case AccountType.ShareCount: target.ShareCount = (int)item.Amount; break; } } return target; }