public UserDtoToCommandLayer() { CreateMap <CreateAUserDto, CreateAUserCommand>(); CreateMap <UpdateAUserDto, UpdateAUserCommand>() .Ignore(command => command.AcceptedNotifications) .Ignore(command => command.AcceptedNotifiers) .AfterMap((dto, command) => { command.AcceptedNotifications = EnumerationFlagsHelpers.ToInteger(dto.AcceptedNotifications); command.AcceptedNotifiers = EnumerationFlagsHelpers.ToInteger(dto.AcceptedNotifiers); }); }
public void Setup() { var acceptedNotifiers = new[] { NotifierType.InApp, NotifierType.Mail }; var acceptedNotifications = new[] { NotificationType.CreatedSuggestion, NotificationType.NewCommentOnYourSuggestion }; var validCommand = new UpdateAUserCommand { UserId = "any user id", Email = "*****@*****.**", AcceptedNotifications = EnumerationFlagsHelpers.ToInteger(acceptedNotifications), AcceptedNotifiers = EnumerationFlagsHelpers.ToInteger(acceptedNotifiers) }; _repository = new UserRepository(_dbContext); _validationContext = new UpdateAUserValidationContext(validCommand, _repository); CreateTheUser(); }
public UserDataToDtoLayer() { CreateMap <User, UserDto>(); CreateMap <UserNotificationSetting, UserNotificationSettingDto>() .Ignore(dto => dto.AcceptedNotifications) .Ignore(dto => dto.AcceptedNotifiers) .AfterMap((dataModel, dto) => { dto.AcceptedNotifications = EnumerationFlagsHelpers.ToStrings <NotificationType>(dataModel.AcceptedNotifications); dto.AcceptedNotifiers = EnumerationFlagsHelpers.ToStrings <NotifierType>(dataModel.AcceptedNotifiers); }); CreateMap <UserNotification, UserNotificationDto>().AfterMap((dataModel, dto) => { dto.Content = dataModel.Notification.Content; dto.Title = dataModel.Notification.Title; dto.Type = dataModel.Notification.Type.ToString(); }); }