public CommandModelDTO SavePayment(CommandModelDTO commandModelDTO) { CommandModel commandModel = commandMapper.ToEntity(commandModelDTO); commandModel.State = new PendingState(); commandModel.Execute(); // command pending return(commandMapper.ToDTO(commandDAO.Save(commandModel))); }
public CommandModelDTO Cancel(CommandModelDTO commandModelDTO) { CommandModel commandModel = commandMapper.ToEntity(commandModelDTO); commandModel.State = new CanceledState(); commandModel.Execute(); // command canceled return(commandMapper.ToDTO(commandDAO.Update(commandModel))); }
public CommandModelDTO Pay(CommandModelDTO commandModelDTO) { CommandModel commandModel = commandMapper.ToEntity(commandModelDTO); if (commandModel.ChoicePaiment != null && commandModel.ChoicePaiment.Equals("PayPal")) { context.paiement = new PaypalServiceImpl(); } else if (commandModel.ChoicePaiment != null && commandModel.ChoicePaiment.Equals("Cash")) { context.paiement = new CashServiceImpl(); } context.Pay(); commandModel.State = new FinishedState(); commandModel.Execute(); // command finished return(commandMapper.ToDTO(commandDAO.Update(commandModel))); }
public CommandModel CreateCommandModel() { var model = new CommandModel(); // run this alternate command for any help-like parameter model.Command("{show help}", IsHelpOption, (m, v) => { }).Execute(ShowHelp); // otherwise use these switches model.Option<StartOptions, string>( "server", "s", Resources.ProgramOutput_ServerOption, (options, value) => options.ServerFactory = value); model.Option<StartOptions, string>( "url", "u", Resources.ProgramOutput_UriOption, (options, value) => options.Urls.Add(value)); model.Option<StartOptions, int>( "port", "p", Resources.ProgramOutput_PortOption, (options, value) => options.Port = value); model.Option<StartOptions, string>( "directory", "d", Resources.ProgramOutput_DirectoryOption, (options, value) => options.Settings["directory"] = value); model.Option<StartOptions, string>( "traceoutput", "o", Resources.ProgramOutput_OutputOption, (options, value) => options.Settings["traceoutput"] = value); model.Option<StartOptions, string>( "settings", Resources.ProgramOutput_SettingsOption, LoadSettings); model.Option<StartOptions, string>( "boot", "b", Resources.ProgramOutput_BootOption, (options, value) => options.Settings["boot"] = value); model.Option<StartOptions, int>( "devMode", "dev", Resources.ProgramOutput_DevModeOption, (options, value) => options.Settings["devMode"] = value.ToString()); /* Disabled until we need to consume it anywhere. model.Option<StartOptions, string>( "verbosity", "v", "Set output verbosity level.", (options, value) => options.Settings["traceverbosity"] = value); */ // and take the name of the application startup model.Parameter<string>((cmd, value) => { var options = cmd.Get<StartOptions>(); if (options.AppStartup == null) { options.AppStartup = value; } else { options.AppStartup += " " + value; } }); // to call this action model.Execute<StartOptions>(RunServer); return model; }
public static CommandModel CreateCommandModel() { var model = new CommandModel(); // run this alternate command for any help-like parameter model.Command("{show help}", IsHelpOption, (m, v) => { }).Execute(ShowHelp); // otherwise use these switches model.Option <StartOptions, string>( "server", "s", Resources.ProgramOutput_ServerOption, (options, value) => options.ServerFactory = value); model.Option <StartOptions, string>( "url", "u", Resources.ProgramOutput_UriOption, (options, value) => options.Urls.Add(value)); model.Option <StartOptions, int>( "port", "p", Resources.ProgramOutput_PortOption, (options, value) => options.Port = value); model.Option <StartOptions, string>( "directory", "d", Resources.ProgramOutput_DirectoryOption, (options, value) => options.Settings["directory"] = value); model.Option <StartOptions, string>( "traceoutput", "o", Resources.ProgramOutput_OutputOption, (options, value) => options.Settings["traceoutput"] = value); model.Option <StartOptions, string>( "settings", Resources.ProgramOutput_SettingsOption, LoadSettings); model.Option <StartOptions, string>( "boot", "b", Resources.ProgramOutput_BootOption, (options, value) => options.Settings["boot"] = value); /* Disabled until we need to consume it anywhere. * model.Option<StartOptions, string>( * "verbosity", "v", "Set output verbosity level.", * (options, value) => options.Settings["traceverbosity"] = value); */ // and take the name of the application startup model.Parameter <string>((cmd, value) => { var options = cmd.Get <StartOptions>(); if (options.AppStartup == null) { options.AppStartup = value; } else { options.AppStartup += " " + value; } }); // to call this action model.Execute <StartOptions>(RunServer); return(model); }