public PostResultDTO LaunchATest(NewLaunchCommandDTO newLaunch) { PostResultDTO result = null; try { bool created = this.launchManager.CreateLaunchCommand(newLaunch); if (created) { result = new PostResultDTO() { Successful = true, Payload = true, Message = "A Launch Command has been created, test in in the queue" }; } else { result = new PostResultDTO() { Successful = true, Payload = false, Message = "A duplicate launch command already exists, and has yet to be executed" }; } } catch (Exception exp) { return(new PostResultDTO() { Successful = false, ErrorMessage = exp.Message, Payload = exp.ToString() }); } return(result); }
public bool CreateLaunchCommand(NewLaunchCommandDTO newLaunch) { if (newLaunch.DontCreateDuplicated && this.DoesAnUnexecutedLaunchCommandAlreadyExist(newLaunch.TestGuid)) { return(false); } LaunchCommand newCommand = new LaunchCommand() { DateCreated = DateTime.Now, TestId = this.GetTestId(newLaunch.TestGuid), CommandText = "LAUNCH", DateScheduled = newLaunch.ScheduledDate, LaunchedByUserGuuid = newLaunch.LaunchedByUserGuid, LaunchedByUserName = newLaunch.LaunchedByUserName, Parameters = newLaunch.Parameters, }; dbContext.LaunchCommands.Add(newCommand); dbContext.SaveChanges(); return(true); }