public ResultDto NewJob(JobDto jobDto) { return(Result(() => { long?ownerId = GetCurrentSessionUser()?.Id; var command = new AddJobCommand { Name = jobDto.Name, Type = jobDto.Type, IsSystemJob = jobDto.IsSystemJob, Description = jobDto.Description, OwnerUserId = ownerId, Created = DateTime.Now, SiteId = jobDto.SiteId, }; CommandDispatcher.Send(command); })); }
public static void Configure(CommandLineApplication app, CommandLineOptions options) { app.Command("test", c => TestCommand.Configure(c, options)); app.Command("serverInfo", c => ApplicationInfoCommand.Configure(c, options)); app.Command("login", c => LoginCommand.Configure(c, options)); app.Command("changePassword", c => ChangePasswordCommand.Configure(c, options)); app.Command("displayConfig", c => DisplayConfigurationCommand.Configure(c, options)); app.Command("changeEndpoint", c => ChangeEndpointCommand.Configure(c, options)); app.Command("getActiveJobs", c => GetJobsCommand.Configure(c, options)); app.Command("getJobHistory", c => GetJobHistoryCommand.Configure(c, options)); app.Command("addJob", c => AddJobCommand.Configure(c, options)); app.Command("addFeed", c => AddFeedCommand.Configure(c, options)); app.Command("testFeed", c => TestFeedCommand.Configure(c, options)); app.Command("importFeeds", c => ImportFeedsCommand.Configure(c, options)); app.Command("updateWeather", c => UpdateForecastsCommand.Configure(c, options)); app.OnExecute(() => { options.Command = new RootCommand(app); return(0); }); }
public async Task <IActionResult> Post(AddJobModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (model.CommandId == Guid.Empty) { model.CommandId = NewId.NextGuid(); } var command = new AddJobCommand(model); await Send(command); return(Accepted(new PostResult <AddJobCommand>() { CommandId = model.JobId, Timestamp = command.Timestamp })); }
private dynamic AddJob(AddJobCommand command) { var commandResult = commandInvokerFactory.Handle <AddJobCommand, CommandResult>(command); return(Response.AsJson(new { success = commandResult.Success, message = commandResult.GetErrors() })); }