protected override Command CreateInsertCommand(Car entity, IAuthenticatedUser user, string selector) { var command = Query <Car> .Single() .Connection(MechanicServicesSeveralVehiclesConnectionClass.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); }
protected override Command CreateDeleteLinksCommand(Car entity, IAuthenticatedUser user, string selector) { switch (selector) { case "UnlinkMechanicFromVehicle": return(Command .NonQuery() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pVehicle_UnlinkMechanic]") .Parameters( p => p.Name("vehicleId").Value(entity.Id) )); case "DeleteCylindersFromVehicle": return(Command .NonQuery() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pVehicle_DeleteCylinders]") .ThrowWhenNoRecordIsUpdated(false) .Parameters( p => p.Name("vehicleId").Value(entity.Id) )); case "DeleteDoorsFromCar": return(Command .NonQuery() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pCar_DeleteDoors]") .ThrowWhenNoRecordIsUpdated(false) .Parameters( p => p.Name("carId").Value(entity.Id) )); default: throw new InvalidOperationException(); } }
public async override Task <IEnumerable <Car> > GetAllAsync() { var result = await Query <Car> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pCar_GetAll]") .ExecuteAsync(); return(result.Records); }
protected override Command CreateDeleteCommand(Mechanic entity, IAuthenticatedUser user, string selector) { return(Command .NonQuery() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pMechanic_Delete]") .Parameters( p => p.Name("mechanicId").Value(entity.Id) )); }
public override IEnumerable <Truck> GetAll() { var result = Query <Truck> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pTruck_GetAll]") .Execute(); return(result.Records); }
public async override Task <(int, IEnumerable <Car>)> GetAsync(CollectionQueryParameters queryParameters) { var result = await Query <Car> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pCar_Get]") .QueryParameters(queryParameters) .Parameters(p => p.Name("count").Count()) .ExecuteAsync(); return(result.Count, result.Records); }
public override (int, IEnumerable <Truck>) Get(CollectionQueryParameters queryParameters) { var result = Query <Truck> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pTruck_Get]") .QueryParameters(queryParameters) .Parameters(p => p.Name("count").Count()) .Execute(); return(result.Count, result.Records); }
public Mechanic GetMechanicForVehicle(int vehicleId) { var result = Query <Mechanic> .Single() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pVehicle_GetMechanic]") .Parameters( p => p.Name("vehicleId").Value(vehicleId) ) .Execute(); return(result.Record); }
public override IEnumerable <Door> GetAll(int carId) { var result = Query <Door> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pCar_GetAllDoors]") .Parameters( p => p.Name("carId").Value(carId) ) .Execute(); return(result.Records); }
public override IEnumerable <Inspection> GetAll(int truckId) { var result = Query <Inspection> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pTruck_GetAllInspections]") .Parameters( p => p.Name("truckId").Value(truckId) ) .Execute(); return(result.Records); }
public async override Task <Car> GetByIdAsync(int carId) { var result = await Query <Car> .Single() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pCar_GetById]") .Parameters( p => p.Name("carId").Value(carId) ) .ExecuteAsync(); return(result.Record); }
public override Truck GetById(int truckId) { var result = Query <Truck> .Single() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pTruck_GetById]") .Parameters( p => p.Name("truckId").Value(truckId) ) .Execute(); return(result.Record); }
public async override Task <IEnumerable <Cylinder> > GetAllAsync(int vehicleId) { var result = await Query <Cylinder> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pVehicle_GetAllCylinders]") .Parameters( p => p.Name("vehicleId").Value(vehicleId) ) .ExecuteAsync(); return(result.Records); }
protected override Command CreateUpdateCommand(Car entity, IAuthenticatedUser user, string selector) { return(Command .NonQuery() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pCar_Update]") .Parameters( p => p.Name("carId").Value(entity.Id), p => p.Name("passengers").Value(entity.Passengers), p => p.Name("model").Value(entity.Model), p => p.Name("updatedBy").Value(entity.UpdatedBy), p => p.Name("mechanicId").Value(entity.MechanicId) )); }
public override (int, IEnumerable <Cylinder>) Get(int vehicleId, CollectionQueryParameters queryParameters) { var result = Query <Cylinder> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pVehicle_GetCylinders]") .QueryParameters(queryParameters) .Parameters(p => p.Name("count").Count()) .Parameters( p => p.Name("vehicleId").Value(vehicleId) ) .Execute(); return(result.Count, result.Records); }
public async override Task<IEnumerable<Vehicle>> GetAllAsync() { var result = await Query<Vehicle> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.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; }
protected override Command CreateUpdateCommand(Mechanic entity, IAuthenticatedUser user, string selector) { if (user != null) { entity.UpdatedBy = (int)user.Id; } return(Command .NonQuery() .Connection(MechanicServicesSeveralVehiclesConnectionClass.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) )); }
protected override Command CreateDeleteLinksCommand(IAuthenticatedUser user) { return(Command .NonQuery() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pTruck_DeleteInspections]") .ThrowWhenNoRecordIsUpdated(false) .OnBeforeCommandExecuted(cmd => { var dependencies = Dependencies(); var entity = (Truck)dependencies.Single().Entity; cmd.Parameters( p => p.Name("truckId").Value(entity.Id) ); })); }
public async override Task<(int, IEnumerable<Vehicle>)> GetAsync(CollectionQueryParameters queryParameters) { var result = await Query<Vehicle> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.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); }
public IEnumerable <Vehicle> GetAllVehiclesForMechanic(int mechanicId) { var result = Query <Vehicle> .Collection() .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pMechanic_GetAllVehicles]") .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.Records); }
public override Vehicle GetById(int vehicleId) { var result = Query<Vehicle> .Single() .Connection(MechanicServicesSeveralVehiclesConnectionClass.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) ) .Execute(); return result.Record; }
protected override Command CreateInsertCommand(Inspection valueObject, IAuthenticatedUser user) { return(Command .NonQuery() .Connection(MechanicServicesSeveralVehiclesConnectionClass.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) ); })); }
protected override Command CreateInsertCommand(Mechanic entity, IAuthenticatedUser user, string selector) { if (user != null) { entity.CreatedBy = (int)user.Id; } var command = Query <Mechanic> .Single() .Connection(MechanicServicesSeveralVehiclesConnectionClass.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); }
public SaveMechanicCommandAggregate(SaveMechanicInputDto mechanic, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName())) { Initialize(mechanic, dependencies); }
public SaveMechanicCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName())) { }