コード例 #1
0
        protected override Command CreateDeleteLinksCommand(Car entity, IAuthenticatedUser user, string selector)
        {
            switch (selector)
            {
            case "UnlinkMechanicFromVehicle": return(Command
                                                     .NonQuery()
                                                     .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                                                     .StoredProcedure("[GarageBoundedContext].[pVehicle_UnlinkMechanic]")
                                                     .Parameters(
                                                         p => p.Name("vehicleId").Value(entity.Id)
                                                         ));

            case "DeleteCylindersFromVehicle": return(Command
                                                      .NonQuery()
                                                      .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                                                      .StoredProcedure("[GarageBoundedContext].[pVehicle_DeleteCylinders]")
                                                      .ThrowWhenNoRecordIsUpdated(false)
                                                      .Parameters(
                                                          p => p.Name("vehicleId").Value(entity.Id)
                                                          ));

            case "DeleteDoorsFromCar": return(Command
                                              .NonQuery()
                                              .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                                              .StoredProcedure("[GarageBoundedContext].[pCar_DeleteDoors]")
                                              .ThrowWhenNoRecordIsUpdated(false)
                                              .Parameters(
                                                  p => p.Name("carId").Value(entity.Id)
                                                  ));

            default: throw new InvalidOperationException();
            }
        }
コード例 #2
0
        protected override Command CreateInsertCommand(Car entity, IAuthenticatedUser user, string selector)
        {
            var command = Query <Car>
                          .Single()
                          .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                          .StoredProcedure("[GarageBoundedContext].[pCar_Insert]")
                          .Parameters(
                p => p.Name("passengers").Value(entity.Passengers),
                p => p.Name("model").Value(entity.Model),
                p => p.Name("createdBy").Value(entity.CreatedBy)
                )
                          .OnBeforeCommandExecuted(cmd =>
            {
                var dependencies = Dependencies();

                var mechanicDependency = (Mechanic)dependencies?.SingleOrDefault()?.Entity;

                if (mechanicDependency != null)
                {
                    entity.MechanicId = mechanicDependency.Id;
                }

                cmd.Parameters(
                    p => p.Name("mechanicId").Value(entity.MechanicId)
                    );
            })
                          .RecordInstance(entity)
                          .MapProperties(
                p => p.Name("Id").Index(0)
                );

            return(command);
        }
コード例 #3
0
        public override IEnumerable <Car> GetAll()
        {
            var result = Query <Car>
                         .Collection()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pCar_GetAll]")
                         .Execute();

            return(result.Records);
        }
コード例 #4
0
 protected override Command CreateDeleteCommand(Car entity, IAuthenticatedUser user, string selector)
 {
     return(Command
            .NonQuery()
            .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
            .StoredProcedure("[GarageBoundedContext].[pCar_Delete]")
            .Parameters(
                p => p.Name("carId").Value(entity.Id)
                ));
 }
コード例 #5
0
        public async override Task <IEnumerable <Mechanic> > GetAllAsync()
        {
            var result = await Query <Mechanic>
                         .Collection()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pMechanic_GetAll]")
                         .ExecuteAsync();

            return(result.Records);
        }
コード例 #6
0
 protected override Command CreateDeleteLinksCommand(Mechanic entity, IAuthenticatedUser user, string selector)
 {
     return(Command
            .NonQuery()
            .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
            .StoredProcedure("[GarageBoundedContext].[pMechanic_UnlinkVehicle]")
            .ThrowWhenNoRecordIsUpdated(false)
            .Parameters(
                p => p.Name("mechanicId").Value(entity.Id)
                ));
 }
コード例 #7
0
        public override (int, IEnumerable <Car>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <Car>
                         .Collection()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pCar_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Execute();

            return(result.Count, result.Records);
        }
コード例 #8
0
        public async override Task <(int, IEnumerable <Mechanic>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Mechanic>
                         .Collection()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pMechanic_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
コード例 #9
0
        public async override Task <Mechanic> GetByIdAsync(int mechanicId)
        {
            var result = await Query <Mechanic>
                         .Single()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pMechanic_GetById]")
                         .Parameters(
                p => p.Name("mechanicId").Value(mechanicId)
                )
                         .ExecuteAsync();

            return(result.Record);
        }
コード例 #10
0
        public override IEnumerable <Cylinder> GetAll(int vehicleId)
        {
            var result = Query <Cylinder>
                         .Collection()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pVehicle_GetAllCylinders]")
                         .Parameters(
                p => p.Name("vehicleId").Value(vehicleId)
                )
                         .Execute();

            return(result.Records);
        }
コード例 #11
0
        public async override Task <IEnumerable <Inspection> > GetAllAsync(int truckId)
        {
            var result = await Query <Inspection>
                         .Collection()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pTruck_GetAllInspections]")
                         .Parameters(
                p => p.Name("truckId").Value(truckId)
                )
                         .ExecuteAsync();

            return(result.Records);
        }
コード例 #12
0
        public override Car GetById(int carId)
        {
            var result = Query <Car>
                         .Single()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pCar_GetById]")
                         .Parameters(
                p => p.Name("carId").Value(carId)
                )
                         .Execute();

            return(result.Record);
        }
コード例 #13
0
        public Mechanic GetMechanicForVehicle(int vehicleId)
        {
            var result = Query <Mechanic>
                         .Single()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pVehicle_GetMechanic]")
                         .Parameters(
                p => p.Name("vehicleId").Value(vehicleId)
                )
                         .Execute();

            return(result.Record);
        }
コード例 #14
0
 protected override Command CreateUpdateCommand(Truck entity, IAuthenticatedUser user, string selector)
 {
     return(Command
            .NonQuery()
            .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
            .StoredProcedure("[GarageBoundedContext].[pTruck_Update]")
            .Parameters(
                p => p.Name("truckId").Value(entity.Id),
                p => p.Name("weight").Value(entity.Weight),
                p => p.Name("model").Value(entity.Model),
                p => p.Name("updatedBy").Value(entity.UpdatedBy),
                p => p.Name("mechanicId").Value(entity.MechanicId)
                ));
 }
コード例 #15
0
        public override (int, IEnumerable <Inspection>) Get(int truckId, CollectionQueryParameters queryParameters)
        {
            var result = Query <Inspection>
                         .Collection()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pTruck_GetInspections]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Parameters(
                p => p.Name("truckId").Value(truckId)
                )
                         .Execute();

            return(result.Count, result.Records);
        }
コード例 #16
0
        public async override Task <IEnumerable <Vehicle> > GetAllAsync()
        {
            var result = await Query <Vehicle>
                         .Collection()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pVehicle_GetAll]")
                         .MapTypes(
                5,
                tm => tm.Type(typeof(Truck)).Index(1),
                tm => tm.Type(typeof(Car)).Index(2),
                tm => tm.Type(typeof(Vehicle)).Index(3)
                )
                         .ExecuteAsync();

            return(result.Records);
        }
コード例 #17
0
        protected override Command CreateUpdateCommand(Mechanic entity, IAuthenticatedUser user, string selector)
        {
            if (user != null)
            {
                entity.UpdatedBy = (int)user.Id;
            }

            return(Command
                   .NonQuery()
                   .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                   .StoredProcedure("[GarageBoundedContext].[pMechanic_Update]")
                   .Parameters(
                       p => p.Name("mechanicId").Value(entity.Id),
                       p => p.Name("name").Value(entity.Name),
                       p => p.Name("updatedBy").Value(entity.UpdatedBy)
                       ));
        }
コード例 #18
0
        public async override Task <(int, IEnumerable <Vehicle>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Vehicle>
                         .Collection()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pVehicle_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .MapTypes(
                5,
                tm => tm.Type(typeof(Truck)).Index(1),
                tm => tm.Type(typeof(Car)).Index(2),
                tm => tm.Type(typeof(Vehicle)).Index(3)
                )
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
コード例 #19
0
        protected override Command CreateDeleteLinksCommand(IAuthenticatedUser user)
        {
            return(Command
                   .NonQuery()
                   .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                   .StoredProcedure("[GarageBoundedContext].[pCar_DeleteDoors]")
                   .ThrowWhenNoRecordIsUpdated(false)
                   .OnBeforeCommandExecuted(cmd =>
            {
                var dependencies = Dependencies();

                var entity = (Car)dependencies.Single().Entity;

                cmd.Parameters(
                    p => p.Name("carId").Value(entity.Id)
                    );
            }));
        }
コード例 #20
0
        public async override Task <Vehicle> GetByIdAsync(int vehicleId)
        {
            var result = await Query <Vehicle>
                         .Single()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pVehicle_GetById]")
                         .Parameters(
                p => p.Name("vehicleId").Value(vehicleId)
                )
                         .MapTypes(
                5,
                tm => tm.Type(typeof(Truck)).Index(1),
                tm => tm.Type(typeof(Car)).Index(2),
                tm => tm.Type(typeof(Vehicle)).Index(3)
                )
                         .ExecuteAsync();

            return(result.Record);
        }
コード例 #21
0
        public Vehicle GetVehicleForMechanic(int mechanicId)
        {
            var result = Query <Vehicle>
                         .Single()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pMechanic_GetVehicle]")
                         .Parameters(
                p => p.Name("mechanicId").Value(mechanicId)
                )
                         .MapTypes(
                5,
                tm => tm.Type(typeof(Truck)).Index(1),
                tm => tm.Type(typeof(Car)).Index(2),
                tm => tm.Type(typeof(Vehicle)).Index(3)
                )
                         .Execute();

            return(result.Record);
        }
コード例 #22
0
        protected override Command CreateInsertCommand(Door valueObject, IAuthenticatedUser user)
        {
            return(Command
                   .NonQuery()
                   .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                   .StoredProcedure("[GarageBoundedContext].[pCar_AddDoors]")
                   .Parameters(
                       p => p.Name("number").Value(valueObject.Number)
                       )
                   .OnBeforeCommandExecuted(cmd =>
            {
                var dependencies = Dependencies();

                var entity = (Car)dependencies.Single().Entity;

                cmd.Parameters(
                    p => p.Name("carId").Value(entity.Id)
                    );
            }));
        }
コード例 #23
0
        protected override Command CreateInsertCommand(Inspection valueObject, IAuthenticatedUser user)
        {
            return(Command
                   .NonQuery()
                   .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                   .StoredProcedure("[GarageBoundedContext].[pTruck_AddInspections]")
                   .Parameters(
                       p => p.Name("date").Value(valueObject.Date)
                       )
                   .OnBeforeCommandExecuted(cmd =>
            {
                var dependencies = Dependencies();

                var entity = (Truck)dependencies.Single().Entity;

                cmd.Parameters(
                    p => p.Name("truckId").Value(entity.Id)
                    );
            }));
        }
コード例 #24
0
        protected override Command CreateInsertCommand(Mechanic entity, IAuthenticatedUser user, string selector)
        {
            if (user != null)
            {
                entity.CreatedBy = (int)user.Id;
            }

            var command = Query <Mechanic>
                          .Single()
                          .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                          .StoredProcedure("[GarageBoundedContext].[pMechanic_Insert]")
                          .Parameters(
                p => p.Name("name").Value(entity.Name),
                p => p.Name("createdBy").Value(entity.CreatedBy)
                )
                          .RecordInstance(entity)
                          .MapProperties(
                p => p.Name("Id").Index(0)
                );

            return(command);
        }
コード例 #25
0
 public SaveTruckCommandAggregate(TruckInputDto truck, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(MechanicServicesSingleVehicleConnectionClass.GetConnectionName()))
 {
     Initialize(truck, dependencies);
 }
コード例 #26
0
 public SaveTruckCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(MechanicServicesSingleVehicleConnectionClass.GetConnectionName()))
 {
 }