コード例 #1
0
        private 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 = _productRepository.GetNextIdentity();

                var productOwner = _productOwnerRepository.Get(tid, productOwnerId);

                var product = new Product(tid, productId, productOwner.ProductOwnerId, name, description, discussionAvailability);

                _productRepository.Save(product);

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
            // TODO: handle null properly
            return(productId.Id);
        }
コード例 #2
0
        public ProductOwnerDTO GetById(int Id)
        {
            ProductOwnerDTO retour = new ProductOwnerDTO();
            ProductOwner    objet  = _repo.Get(Id);

            retour = MapProductOwnerDTO.ToDto(objet);
            return(retour);
        }
コード例 #3
0
        public void EnableProductOwner(EnableProductOwnerCommand command)
        {
            var tenantId = new TenantId(command.TenantId);

            ApplicationServiceLifeCycle.Begin();
            try
            {
                var productOwner = _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);
                    _productOwnerRepository.Save(productOwner);
                }
                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }