public async Task <ActionResult <Candidate> > PostCandidate(Candidate candidate) { WorkLoad workLoad = candidate.WorkLoad; WorkSchedule workSchedule = candidate.WorkSchedule; List <CandidateKnowledge> candidateKnowledges = candidate.CandidateKnowledges; List <CandidateKnowledge> candidateKnowledgesForSave = new List <CandidateKnowledge>(); candidate.WorkSchedule = null; candidate.WorkLoad = null; _context.Candidates.Add(candidate); await _context.SaveChangesAsync(); workLoad.CandidateId = candidate.Id; _context.WorkLoads.Add(workLoad); workSchedule.CandidateId = candidate.Id; _context.WorkSchedules.Add(workSchedule); await _context.SaveChangesAsync(); foreach (CandidateKnowledge item in candidateKnowledges) { CandidateKnowledge candidateKnowledge = new CandidateKnowledge(); candidateKnowledge.CandidateId = candidate.Id; candidateKnowledge.KnowledgeId = item.KnowledgeId; candidateKnowledge.Rate = item.Rate; candidateKnowledgesForSave.Add(candidateKnowledge); //_context.CandidateKnowledges.Add(candidateKnowledge); //await _context.SaveChangesAsync(); } _context.CandidateKnowledges.AddRange(candidateKnowledgesForSave); await _context.SaveChangesAsync(); candidate.WorkSchedule = null; candidate.WorkLoad = null; return(candidate); }
public async Task <ActionResult> SetWorkLoads([FromBody] WorkLoad model) { try { return(Ok(await _wlRepository.Create(model))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult WorkLog(int id, WorkLoad model) { try { var workRepo = new WorkLoadRepository(); int userId = Int32.Parse(Session["UserId"].ToString()); workRepo.AddWorkLoad(id, userId, model); return(RedirectToAction("Details", new { id = id })); } catch { return(View()); } }
public async Task <IActionResult> PutCandidate(int id, Candidate candidate) { if (id != candidate.Id) { return(BadRequest()); } try { WorkLoad workLoad = candidate.WorkLoad; WorkSchedule workSchedule = candidate.WorkSchedule; List <CandidateKnowledge> candidateKnowledges = candidate.CandidateKnowledges; List <CandidateKnowledge> candidateKnowledgesForSave = new List <CandidateKnowledge>(); candidate.WorkSchedule = null; candidate.WorkLoad = null; _context.Entry(candidate).State = EntityState.Modified; await _context.SaveChangesAsync(); _context.Entry(workLoad).State = EntityState.Modified; await _context.SaveChangesAsync(); _context.Entry(workSchedule).State = EntityState.Modified; await _context.SaveChangesAsync(); foreach (CandidateKnowledge item in candidateKnowledges) { _context.Entry(item).State = EntityState.Modified; await _context.SaveChangesAsync(); } } catch (DbUpdateConcurrencyException) { if (!CandidateExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void Player_DataReceived(object sender, DataReceivedInfo args) { if (IsCaptionStream(args.StreamAttributes)) { var player = (SMFPlayer)sender; var workload = new WorkLoad() { data = args.Data, timeOffset = player.CalculateRelativeMediaPosition(args.DataChunk.Timestamp), //Added a workaround for an issue w/ the SSME that causes the //duration data to be empty. In this case we'll default to 2 seconds //TODO: Remove this once the issue has been fix in the SSME. endTime = args.DataChunk.Timestamp.Add(args.DataChunk.Duration != TimeSpan.Zero ? args.DataChunk.Duration : TimeSpan.FromMilliseconds(2002)) }; workerQueue.Enqueue(workload); if (workerQueue.Count == 1) { RunWorkLoad(workload); } } }
void RunWorkLoad(WorkLoad workload) { Thread thread = new Thread(Operation); thread.Start(workload); }