public long UpdateCardType(CardTypeDTO t_CardType) { using (B2CDbContext ctx = new B2CDbContext()) { BaseService <CardTypeEntity> cardTypebs = new BaseService <CardTypeEntity>(ctx); BaseService <UserInfoEntity> bs = new BaseService <UserInfoEntity>(ctx); if (cardTypebs.GetById(t_CardType.Id) != null) { CardTypeEntity cardTypeEntity = new CardTypeEntity(); cardTypeEntity.CardImage = t_CardType.CardImage; cardTypeEntity.CardPrice = t_CardType.CardPrice; cardTypeEntity.CardTypeName = t_CardType.CardTypeName; foreach (var item in bs.GetAll().Where(a => t_CardType.UserInfoIds.Contains(a.Id))) { cardTypeEntity.UserInfos.Add(item); } ctx.SaveChanges(); return(cardTypeEntity.Id); } else { return(0); } } }
private CardTypeDTO ToDTO(CardTypeEntity cardTypeEntity) { CardTypeDTO cardType = new CardTypeDTO(); cardType.Id = cardTypeEntity.Id; cardType.CardTypeName = cardTypeEntity.CardTypeName; cardType.CardImage = cardTypeEntity.CardImage; cardType.CardPrice = cardTypeEntity.CardPrice; cardType.UserInfoIds = cardTypeEntity.UserInfos.Select(a => a.Id).ToArray(); return(cardType); }
public CardTypeEventEntity(UserAccessUnitType cardType) { OldValue = new CardTypeEntity(); NewValue = new CardTypeEntity(); Mapper.Map(cardType, OldValue); }