public async Task <IActionResult> Edit(int id, [Bind("ID,ApplicationLink,Company,DatePosted,Experience,Hours,JobID,JobTitle,LanguagesUsed,Location,Salary")] JsonJob jsonJob) { if (id != jsonJob.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(jsonJob); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JsonJobExists(jsonJob.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(jsonJob)); }
public ActionResult <JsonStatus> ProblemsPost([FromBody] JsonJob instance) { // Sanity check job var inputErr = JsonIO.Validate(instance.Instance); if (inputErr != null) { _logger.LogWarning($"POST calculation had error: {inputErr}"); return(BadRequest(inputErr)); } // Create calculation job int calcId = _jobManager.GetNextId(); var calc = new Calculation(calcId, instance, null); if (calc.Problem.Configuration == null) // Set a default config, if none is given { calc.Problem.Configuration = new ObjectModel.Configuration.Configuration(ObjectModel.MethodType.ExtremePointInsertion, false); } calc.Status.ProblemUrl = $"{SUB_CALCULATION_PROBLEMS}/{calcId}"; calc.Status.StatusUrl = $"{SUB_CALCULATION_PROBLEMS}/{calcId}/status"; calc.Status.SolutionUrl = $"{SUB_CALCULATION_PROBLEMS}/{calcId}/solution"; // Log _logger.LogInformation($"POST calculation (got ID {calcId})"); // Enqueue the problem _jobManager.Enqueue(calc); return(Ok(calc.Status)); }
public Calculation(int id, JsonJob instance, Action <string> logger) { Id = id; Problem = instance; Status = new JsonStatus() { Id = id }; Logger = logger; }
public async Task <IActionResult> Create([Bind("ID,ApplicationLink,Company,DatePosted,Experience,Hours,JobID,JobTitle,LanguagesUsed,Location,Salary")] JsonJob jsonJob) { if (ModelState.IsValid) { _context.Add(jsonJob); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(jsonJob)); }
/// <summary> /// Gets a calculation. /// </summary> /// <param name="id">The id of the calculation.</param> /// <returns>The calculation, or <code>null</code> if the calculation is unknown.</returns> public JsonJob GetCalculation(int id) { // Init JsonJob problem = null; // We need to synchronize access to the backlog _backlogAccess.EnterReadLock(); try { _idToCalculation.TryGetValue(id, out Calculation calc); problem = calc?.Problem; } finally { // Release the lock on the resource _backlogAccess.ExitReadLock(); } // Return result return(problem); }
public OfflineJobViewModel(JsonJob job) { _jsonJob = job; }