コード例 #1
0
        public async Task <Data.Candidate> ModifyCandidate(Data.Candidate candidate)
        {
            try
            {
                Data.Candidate existCandidate =
                    await _dbContext
                    .Candidates
                    .SingleOrDefaultAsync(c => c.CandidateId.Equals(candidate.CandidateId));

                if (existCandidate == null)
                {
                    await _dbContext.Candidates.AddAsync(candidate);
                }
                else
                {
                    _dbContext.Candidates.Update(candidate);
                }

                await _dbContext.SaveChangesAsync();

                return(existCandidate ?? candidate);
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
コード例 #2
0
        private void ModifyTable(ICollection <Candidate> candidatesToAssign, Candidate candidate, Target target, DateTime requestTime, DateTime assignedTime, TimeSpan algoExecution, int algo, int maxLoad)
        {
            Data.Candidate modCandidate = _dataBusiness.GetCandidate(candidate.Id);
            modCandidate.TotalTravel += (int)candidate.DistanceToTarget;
            modCandidate.IsAssigned   = true;
            modCandidate.Load++;

            Data.Target modTarget = _dataBusiness.GetTarget(target.Id);
            modTarget.LastRequest = requestTime;

            string transactionId = Guid.NewGuid().ToString();

            Data.Transaction modTransaction = new Data.Transaction
            {
                TransactionId          = transactionId,
                From                   = modTarget,
                To                     = modCandidate,
                RequestAt              = requestTime,
                AssigneeAt             = assignedTime,
                Distance               = candidate.DistanceToTarget,
                AlgorithmExecutionTime = algoExecution,
                Algorithm              = algo == 1 ? "Nearest Neighbor" : "Round Robin",
                Candidates             = Newtonsoft.Json.JsonConvert.SerializeObject(candidatesToAssign),
                MaxLoad                = maxLoad,
            };

            _ = _dataBusiness.ModifyCandidate(modCandidate);
            _ = _dataBusiness.ModifyTarget(modTarget);
            _ = _dataBusiness.ModifyTransaction(modTransaction);
            // _ = _dataBusiness.CreateJsonFile($"Transaction_{transactionId}", candidatesToAssign);
        }
コード例 #3
0
 private static Models.CandidateSummary ConvertToModelSummary(Data.Candidate c)
 {
     return(new Models.CandidateSummary
     {
         Id = c.Id,
         RoleId = c.RoleId,
         Firstname = c.Firstname,
         Lastname = c.Lastname,
     });
 }
コード例 #4
0
 private static Models.Candidate ConvertToModel(Data.Candidate c)
 {
     return(new Models.Candidate
     {
         Id = c.Id,
         RoleId = c.RoleId,
         Firstname = c.Firstname,
         Lastname = c.Lastname,
         AptitudeAssessment = GetlatestAptitudeAssessment(c.Assessments),
         BehaviourAssessment = GetlatestBehaviourAssessment(c.Assessments),
     });
 }
コード例 #5
0
 public static Candidate ToLibCandidate(this Data.Candidate candidate)
 {
     return new Candidate
     {
         Id = candidate.CandidateId,
         IsAssigned = candidate.IsAssigned,
         Load = candidate.Load,
         Location = new Location
         {
             Latitude = candidate.Latitude,
             Longitude = candidate.Longitude
         }
     };
 }
コード例 #6
0
 public async Task Update(Data.Candidate candidate)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 public async Task Create(Data.Candidate candidate)
 {
     await _context.Candidates.AddAsync(candidate);
 }