public void InitiateDiscussion(InitiateDiscussionCommand command) { ApplicationServiceLifeCycle.Begin(); try { var product = this.productRepository.Get(new TenantId(command.TenantId), new ProductId(command.ProductId)); if (product == null) { throw new InvalidOperationException( string.Format("Unknown product of tenant id: {0} and product id: {1}.", command.TenantId, command.ProductId)); } product.InitiateDiscussion(new DiscussionDescriptor(command.DiscussionId)); this.productRepository.Save(product); var processId = ProcessId.ExistingProcessId(product.DiscussionInitiationId); var tracker = this.processTrackerRepository.Get(command.TenantId, processId); tracker.MarkProcessCompleted(); this.processTrackerRepository.Save(tracker); ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } }
public void ChangeTeamMemberEmailAddress(ChangeTeamMemberEmailAddressCommand command) { var tenantId = new TenantId(command.TenantId); ApplicationServiceLifeCycle.Begin(); try { var productOwner = this.productOwnerRepository.Get(tenantId, command.Username); if (productOwner != null) { productOwner.ChangeEmailAddress(command.EmailAddress, command.OccurredOn); this.productOwnerRepository.Save(productOwner); } var teamMember = this.teamMemberRepository.Get(tenantId, command.Username); if (teamMember != null) { teamMember.ChangeEmailAddress(command.EmailAddress, command.OccurredOn); this.teamMemberRepository.Save(teamMember); } ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } }
string NewProductWith(string tenantId, string productOwnerId, string name, string description, DiscussionAvailability discussionAvailability) { var tid = new TenantId(tenantId); var productId = default(ProductId); ApplicationServiceLifeCycle.Begin(); try { productId = this.productRepository.GetNextIdentity(); var productOwner = this.productOwnerRepository.Get(tid, productOwnerId); var product = new Product(tid, productId, productOwner.ProductOwnerId, name, description, discussionAvailability); this.productRepository.Save(product); ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } // TODO: handle null properly return(productId.Id); }
public void ChangeTeamMemberName(ChangeTeamMemberNameCommand command) { var tenantId = new TenantId(command.TenantId); ApplicationServiceLifeCycle.Begin(); try { var productOwner = _productOwnerRepository.Get(tenantId, command.Username); if (productOwner != null) { productOwner.ChangeName(command.FirstName, command.LastName, command.OccurredOn); _productOwnerRepository.Save(productOwner); } var teamMember = _teamMemberRepository.Get(tenantId, command.Username); if (teamMember != null) { teamMember.ChangeName(command.FirstName, command.LastName, command.OccurredOn); _teamMemberRepository.Save(teamMember); } ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } }
public void PublishNotifications() { ApplicationServiceLifeCycle.Begin(false); try { this.notificationPublisher.PublishNotifications(); ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } }
void RequestProductDiscussionFor(Product product) { ApplicationServiceLifeCycle.Begin(); try { product.RequestDiscussion(RequestDiscussionIfAvailable()); this.productRepository.Save(product); ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } }
public void CheckForTimedOutProccesses() { ApplicationServiceLifeCycle.Begin(); try { var trackers = this.processTrackerRepository.GetAllTimedOut(); foreach (var tracker in trackers) { tracker.InformProcessTimedOut(); this.processTrackerRepository.Save(tracker); } ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } }
public void DisableTeamMember(DisableTeamMemberCommand command) { var tenantId = new TenantId(command.TenantId); ApplicationServiceLifeCycle.Begin(); try { var teamMember = this.teamMemberRepository.Get(tenantId, command.Username); if (teamMember != null) { teamMember.Disable(command.OccurredOn); this.teamMemberRepository.Save(teamMember); } ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } }
public void EnableProductOwner(EnableProductOwnerCommand command) { var tenantId = new TenantId(command.TenantId); ApplicationServiceLifeCycle.Begin(); try { var productOwner = this.productOwnerRepository.Get(tenantId, command.Username); if (productOwner != null) { productOwner.Enable(command.OccurredOn); } else { productOwner = new ProductOwner(tenantId, command.Username, command.FirstName, command.LastName, command.EmailAddress, command.OccurredOn); this.productOwnerRepository.Save(productOwner); } ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } }
public void StartDiscussionInitiation(StartDiscussionInitiationCommand command) { ApplicationServiceLifeCycle.Begin(); try { var product = this.productRepository.Get(new TenantId(command.TenantId), new ProductId(command.ProductId)); if (product == null) { throw new InvalidOperationException( string.Format("Unknown product of tenant id: {0} and product id: {1}.", command.TenantId, command.ProductId)); } var timedOutEventName = typeof(ProductDiscussionRequestTimedOut).Name; var tracker = new TimeConstrainedProcessTracker( tenantId: command.TenantId, processId: ProcessId.NewProcessId(), description: "Create discussion for product: " + product.Name, originalStartTime: DateTime.UtcNow, allowableDuration: 5L * 60L * 1000L, totalRetriesPermitted: 3, processTimedOutEventType: timedOutEventName); this.processTrackerRepository.Save(tracker); product.StartDiscussionInitiation(tracker.ProcessId.Id); this.productRepository.Save(product); ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } }
public void TimeOutProductDiscussionRequest(TimeOutProductDiscussionRequestCommand command) { ApplicationServiceLifeCycle.Begin(); try { var processId = ProcessId.ExistingProcessId(command.ProcessId); var tenantId = new TenantId(command.TenantId); var product = this.productRepository.GetByDiscussionInitiationId(tenantId, processId.Id); SendEmailForTimedOutProcess(product); product.FailDiscussionInitiation(); this.productRepository.Save(product); ApplicationServiceLifeCycle.Success(); } catch (Exception ex) { ApplicationServiceLifeCycle.Fail(ex); } }