using System; using ShareeBike.Model.Connector; using ShareeBike.Model.Device; using ShareeBike.Model.User; using ShareeBike.View; using ShareeBike.ViewModel.Bikes.Bike.BC.RequestHandler; using BikeInfoMutable = ShareeBike.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable; namespace ShareeBike.ViewModel.Bikes.Bike.BC { public static class RequestHandlerFactory { /// Provides info about the smart device (phone, tablet, ...) /// View model to be used for progress report and unlocking/ locking view. public static IRequestHandler Create( BikeInfoMutable selectedBike, Func isConnectedDelegate, Func connectorFactory, Func viewUpdateManager, ISmartDevice smartDevice, IViewService viewService, IBikesViewModel bikesViewModel, IUser activeUser) { switch (selectedBike.State.Value) { case Model.State.InUseStateEnum.Disposable: // Bike can be booked. return new Disposable( selectedBike, isConnectedDelegate, connectorFactory, viewUpdateManager, smartDevice, viewService, bikesViewModel, activeUser); case Model.State.InUseStateEnum.Reserved: // Reservation can be canceled. return new Reserved( selectedBike, isConnectedDelegate, connectorFactory, viewUpdateManager, smartDevice, viewService, bikesViewModel, activeUser); default: // No action using app possible. return new Booked( selectedBike, viewService, bikesViewModel, activeUser); } } } }