Ejemplo n.º 1
0
        public async Task <IBasicResult> ChangeTitleAsync(Guid taskId, string title)
        {
            ISingleObjectResult <UZTask> getResult = (SingleObjectResult <UZTask>) await UnitOfWork.Repository.GetByIdAsync(taskId);

            getResult.Object.Title = title;

            if (getResult.IsSuccessful)
            {
                IBasicResult updateResult = await UnitOfWork.Repository.AddOrUpdateAsync(getResult.Object);

                updateResult.AffectedResources.AddRange(getResult.AffectedResources);
            }

            return(getResult);
        }
Ejemplo n.º 2
0
        public async Task CanAddDomainObjects()
        {
            WindsorContainer container = new WindsorContainer();

            container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel));

            container.Register
            (
                // Repositories
                Component.For <IRepository <Guid, UZTask> >()
                .ImplementedBy <MemoryRepository <Guid, UZTask> >()
                .LifestyleTransient(),

                // Id generators
                Component.For <IIdGenerator <Guid> >()
                .ImplementedBy <GuidIdGenerator>(),

                // Specs
                Component.For <ISpecification <Guid, UZTask> >()
                .ImplementedBy <AddOrUpdateTaskSpec>()
                .LifestyleTransient()
            );

            IRepository <Guid, UZTask> repo2 = container.Resolve <IRepository <Guid, UZTask> >();

            List <ISpecification <Guid, UZTask> > specs = new List <ISpecification <Guid, UZTask> >();

            specs.Add(new AddOrUpdateTaskSpec());

            IRepository <Guid, UZTask> repo =
                new MemoryRepository <Guid, UZTask>(new GuidIdGenerator(), specs);

            UZTask testTask = new UZTask();
            await repo.AddOrUpdateAsync(testTask);

            ISingleObjectResult <UZTask> gotTask = await repo.GetByIdAsync(testTask.Id);

            Assert.IsFalse(gotTask.Object.IsDirty);
            Assert.AreEqual(testTask, gotTask);
        }