public HandlerResult Handle(ToiletManagerState state, ICommand command, IRepository <IDbProperties> repository) { switch (command) { case CreateToilet toilet: { if (repository.CreateToilet(toilet.Toilet)) { return(new HandlerResult(new CreatedToilet(toilet.Toilet))); } return(new HandlerResult($"Toilet {toilet.Toilet.Tag} could not be created at this time!", "", "")); } default: return(HandlerResult.NotHandled(command, command.Commander, command.CommandId)); } }
public HandlerResult Handle(BathRoomManagerState state, ICommand command, IRepository <IDbProperties> repository) { switch (command) { case CreateBathRoom bathroom: { if (repository.CreateBathRoom(bathroom.BathRoom)) { return(new HandlerResult(new CreatedBathRoom(bathroom.BathRoom))); } return(new HandlerResult($"BathRoom {bathroom.BathRoom.Tag} could not be created at this time!", "", "")); } default: return(HandlerResult.NotHandled(command, command.Commander, command.CommandId)); } }
public HandlerResult Handle(KitchenState state, ICommand command, IRepository <IDbProperties> repository) { switch (command) { case InstallSensor senors: { if (repository.InstallKitchenSensors(state, out var newstate)) { return(new HandlerResult(new InstalledSensor(newstate.Sensors))); } return(new HandlerResult($"Sensors for {state.Type} could not be installed at this time!")); } default: return(HandlerResult.NotHandled(command)); } }
public HandlerResult Handle(ToiletState state, ICommand command, IRepository <IDbProperties> repository) { switch (command) { case InstallSensor senors: { if (repository.InstallToiletSensors(state, out var newstate)) { return(new HandlerResult(new InstalledSensor(newstate.Sensors))); } return(new HandlerResult($"Sensors for {state.Tag} could not be installed at this time!", string.Empty, string.Empty)); } default: return(HandlerResult.NotHandled(command, command.Commander, command.CommandId)); } }
public HandlerResult Handle(FloorState state, ICommand command, IRepository <IDbProperties> repository) { switch (command) { case CreateKitchen createKitchen: { var kitchen = createKitchen.Kitchen; if (repository.CreateKitchen(kitchen)) { return(new HandlerResult(new CreatedKitchen(kitchen))); } return(new HandlerResult($"Kitchen {kitchen.Tag} could not be created at this time!")); } default: return(HandlerResult.NotHandled(command)); } }
public HandlerResult Handle(HostelManagerState state, ICommand command, IRepository <IDbProperties> repository) { switch (command) { case ConstructHostel construct: { var hostel = construct.Construction; if (!state.Constructed) { if (repository.ConstructHostel(hostel)) { return(new HandlerResult(new ConstructedHostel(hostel))); } return(new HandlerResult($"Hostel {hostel.Detail.Name} could not be constructed at this time!")); } return(new HandlerResult($"Hostel {hostel.Detail.Name} alread exist. Did the government demonish your hostel?")); } case CreateFloor createFloor: { var floor = createFloor.Floor; if (repository.CreateFloor(floor)) { return(new HandlerResult(new CreatedFloor(floor))); } return(new HandlerResult($"Floor {floor.Tag} could not be created at this time!")); } case CreateSepticTank createSeptic: { var tank = createSeptic.Spec; if (repository.CreateSepticTank(tank)) { return(new HandlerResult(new CreatedSepticTank(tank))); } return(new HandlerResult($"SepticTank {tank.Tag} could not be created at this time!")); } case CreateWaterReservoir createWater: { var water = createWater.Spec; if (repository.CreateReservoir(water)) { return(new HandlerResult(new CreatedWaterReservoir(water))); } return(new HandlerResult($"Water Reservoir {water.Tag} could not be created at this time!")); } case CreatePerson person: { var input = person.Payload; if (repository.CreatePerson(input)) { return(new HandlerResult(new PersonCreated(input))); } return(new HandlerResult($"Registration Failed")); } default: return(HandlerResult.NotHandled(command)); } }