Beispiel #1
0
        public async Task <Result <long> > Handle(CreateCatalogCommand command, CancellationToken cancellationToken)
        {
            Owner owner = uow.Owners.GetById(command.OwnerId);

            if (owner == null)
            {
                return(Result.NotFound());
            }

            if (owner.OwnerId != command.UserId)
            {
                return(Result.Unauthorized());
            }

            var policy = AddQuestionsCatalogPolicyFactory.Create(owner.MembershipLevel);
            QuestionsCatalog catalog = owner.AddQuestionsCatalog(command.Name, policy);
            await uow.Save();

            return(Result.Ok(catalog.CatalogId));
        }