Exemplo n.º 1
0
            public static WorkOrder CreateWorkOrder(Guid id, string userCreated, Order order)
            {
                // prepare
                var odataProvider   = new OdataProvider();
                var modelConverter  = new ModelConverter(new TypeConverterProvider(), new DateTimeProvider());
                var writeRepository = new WorkOrderWriteRepository(new PersistenceContext(new PersistenceConfiguration(RepositoryTestsHelper.ConnectionString)), modelConverter);
                var readRepository  = new WorkOrderReadRepository(new PersistenceContext(new PersistenceConfiguration(RepositoryTestsHelper.ConnectionString)), odataProvider, modelConverter);

                // create
                var startCreatedOn = new CreatedOn(DateTime.Now.AddHours(-5).ToUniversalTime());

                var operational = new Operational(Status.Open);
                var workOrder   = new WorkOrder(id, true, order, operational, userCreated, startCreatedOn);

                writeRepository.CreateAsync(workOrder).GetAwaiter().GetResult();

                // result
                var result = readRepository.GetAsync(id).Result;

                return(result);
            }
Exemplo n.º 2
0
        public static WorkOrder CreateWorkOrder(Guid id, Order order)
        {
            // prepare
            var writeRepository = new WorkOrderWriteRepository(new PersistenceContext(new PersistenceConfiguration(DatabaseHelper.ConnectionString)), new ModelConverter(new TypeConverterProvider(), new DateTimeProvider()));
            var readRepository  = new WorkOrderReadRepository(new PersistenceContext(new PersistenceConfiguration(DatabaseHelper.ConnectionString)), new OdataProvider(), new ModelConverter(new TypeConverterProvider(), new DateTimeProvider()));

            // create
            var entity = new WorkOrder(id);

            entity.CreatedOn   = new CreatedOn(DateTime.UtcNow);
            entity.UserCreated = "UserCreated";
            entity.IsEditable  = false;
            entity.Order       = order;
            entity.Operational = new Operational(Status.Open);


            writeRepository.CreateAsync(entity).GetAwaiter().GetResult();


            // result
            var result = readRepository.GetAsync(id).Result;

            return(result);
        }