Exemplo n.º 1
0
        // DELETE
        public static Task RemoveNationality(NationalityId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new NationalityRepository(context);

            var nationalityService = new NationalityService(repository);
            var command            = new Commands.Delete
            {
                Id = id,
            };

            return(nationalityService.Handle(command));
        }
Exemplo n.º 2
0
        public static Task CreateInvalidNationality()
        {
            var connectionString   = ConnectivityService.GetConnectionString("TEMP");
            var context            = new BookOrganizer2DbContext(connectionString);
            var repository         = new NationalityRepository(context);
            var nationalityService = new NationalityService(repository);

            var nationalityId = new NationalityId(SequentialGuid.NewSequentialGuid());
            var command       = new Commands.Create {
                Id = nationalityId
            };

            return(nationalityService.Handle(command));
        }
Exemplo n.º 3
0
        internal static Task UpdateNationality(Nationality sut)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new NationalityRepository(context);

            var nationalityService = new NationalityService(repository);
            var command            = new Commands.Update
            {
                Id   = sut.Id,
                Name = sut.Name
            };

            return(nationalityService.Handle(command));
        }
Exemplo n.º 4
0
        public static async Task <Nationality> CreateValidNationality()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new NationalityRepository(context);

            var nationalityService = new NationalityService(repository);

            var command = new Commands.Create
            {
                Id   = new NationalityId(SequentialGuid.NewSequentialGuid()),
                Name = "american"
            };

            await nationalityService.Handle(command);

            return(await repository.GetAsync(command.Id));
        }