public async Task ExecuteAsync( UserId userId, ChannelId channelId, ValidChannelName name, ValidChannelPrice price, bool isVisibleToNonSubscribers, DateTime now) { using (var transaction = TransactionScopeBuilder.CreateAsync()) { using (var connection = this.connectionFactory.CreateConnection()) { await connection.ExecuteAsync( UpdateStatement, new { Id = channelId.Value, IsVisibleToNonSubscribers = isVisibleToNonSubscribers, Name = name.Value, Price = price.Value, PriceLastSetDate = now }); } await this.requestSnapshot.ExecuteAsync(userId, SnapshotType.CreatorChannels); transaction.Complete(); } }
public Parsed( Fifthweek.Api.Blogs.Shared.BlogId blogId, ValidChannelName name, ValidChannelPrice price, System.Boolean isVisibleToNonSubscribers) { if (blogId == null) { throw new ArgumentNullException("blogId"); } if (name == null) { throw new ArgumentNullException("name"); } if (price == null) { throw new ArgumentNullException("price"); } if (isVisibleToNonSubscribers == null) { throw new ArgumentNullException("isVisibleToNonSubscribers"); } this.BlogId = blogId; this.Name = name; this.Price = price; this.IsVisibleToNonSubscribers = isVisibleToNonSubscribers; }
public async Task ItShouldNotUpdatePriceLastSetDateIfPriceHasNotChanged() { await this.DatabaseTestAsync(async testDatabase => { this.InitializeTarget(testDatabase); var channel = await this.CreateChannelAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); await this.target.ExecuteAsync( UserId, ChannelId, Name, ValidChannelPrice.Parse(channel.Price), IsVisibleToNonSubscribers, Now); var expectedChannel = new Channel(ChannelId.Value) { IsVisibleToNonSubscribers = IsVisibleToNonSubscribers, Name = Name.Value, Price = channel.Price, PriceLastSetDate = channel.PriceLastSetDate, BlogId = channel.BlogId, CreationDate = channel.CreationDate, IsDiscoverable = channel.IsDiscoverable, }; return(new ExpectedSideEffects { Update = expectedChannel }); }); }
public static NewChannelData.Parsed Parse(this NewChannelData target) { var modelStateDictionary = new System.Web.Http.ModelBinding.ModelStateDictionary(); ValidChannelName parsed0 = null; if (!ValidChannelName.IsEmpty(target.Name)) { System.Collections.Generic.IReadOnlyCollection <string> parsed0Errors; if (!ValidChannelName.TryParse(target.Name, out parsed0, out parsed0Errors)) { var modelState = new System.Web.Http.ModelBinding.ModelState(); foreach (var errorMessage in parsed0Errors) { modelState.Errors.Add(errorMessage); } modelStateDictionary.Add("Name", modelState); } } else { var modelState = new System.Web.Http.ModelBinding.ModelState(); modelState.Errors.Add("Value required"); modelStateDictionary.Add("Name", modelState); } ValidChannelPrice parsed1 = null; System.Collections.Generic.IReadOnlyCollection <string> parsed1Errors; if (!ValidChannelPrice.TryParse(target.Price, out parsed1, out parsed1Errors)) { var modelState = new System.Web.Http.ModelBinding.ModelState(); foreach (var errorMessage in parsed1Errors) { modelState.Errors.Add(errorMessage); } modelStateDictionary.Add("Price", modelState); } if (!modelStateDictionary.IsValid) { throw new Fifthweek.Api.Core.ModelValidationException(modelStateDictionary); } return(new NewChannelData.Parsed( target.BlogId, parsed0, parsed1, target.IsVisibleToNonSubscribers)); }
public static CreateBlogCommand NewCreateBlogCommand( UserId userId, BlogId blogId, ChannelId firstChannelId, NewBlogData data) { return(new CreateBlogCommand( Requester.Authenticated(userId), blogId, firstChannelId, ValidBlogName.Parse(data.Name), ValidChannelPrice.Parse(data.BasePrice))); }
public Parsed( ValidChannelName name, ValidChannelPrice price, System.Boolean isVisibleToNonSubscribers) { if (name == null) { throw new ArgumentNullException("name"); } if (price == null) { throw new ArgumentNullException("price"); } if (isVisibleToNonSubscribers == null) { throw new ArgumentNullException("isVisibleToNonSubscribers"); } this.Name = name; this.Price = price; this.IsVisibleToNonSubscribers = isVisibleToNonSubscribers; }