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(); } }
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); }
public override IEnumerable <Car> GetAll() { var result = Query <Car> .Collection() .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pCar_GetAll]") .Execute(); return(result.Records); }
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) )); }
public async override Task <IEnumerable <Mechanic> > GetAllAsync() { var result = await Query <Mechanic> .Collection() .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName()) .StoredProcedure("[GarageBoundedContext].[pMechanic_GetAll]") .ExecuteAsync(); return(result.Records); }
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) )); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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) )); }
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); }
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); }
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) )); }
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); }
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) ); })); }
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); }
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); }
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) ); })); }
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) ); })); }
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); }
public SaveTruckCommandAggregate(TruckInputDto truck, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())) { Initialize(truck, dependencies); }
public SaveTruckCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())) { }