/// <summary> /// Edit interview interview process /// </summary> /// <param name="process">interview process</param> /// <param name="listRound">list interview round in process</param> /// <returns> /// Success: Interview process /// Error: null / exception /// </returns> public InterviewProcess Edit(InterviewProcess process, List <RoundProcess> listRound) { log.Info(String.Format("Function: Edit - process: {0} - listRound: {1}", process, listRound)); //update interview process InterviewProcess updateProcessResult = _interviewProcessRepository.Update(process); if (updateProcessResult == null) { log.Info(String.Format("Process: {0} - Message: Update interview process failed", process)); } else { //set round order int roundOrder = 1; for (int roundIndex = 0; roundIndex < listRound.Count; roundIndex++) { listRound[roundIndex].RoundOrder = roundIndex + 1; } //find roundProcess that do not in process anymore, then delete it List <RoundProcess> listRoundProcess = _roundProcessRepository.GetByProcessId(process.ID).ToList(); RoundProcess roundProcessFindResult = new RoundProcess(); foreach (RoundProcess roundProcess in listRoundProcess.ToList()) { roundProcessFindResult = listRound.FirstOrDefault(r => r.InterviewRoundID == roundProcess.InterviewRoundID); if (roundProcessFindResult == null) { //relationship not exist in listRound, remove it from database _roundProcessRepository.Delete(roundProcess); } else { //if relationship is exist in list, edit RoundOrder of it and remove it from list round to do not be duplicate when save list roundProcess.RoundOrder = roundProcessFindResult.RoundOrder; _roundProcessRepository.Update(roundProcess); listRound.Remove(roundProcessFindResult); } } //add relationship between round and process foreach (RoundProcess round in listRound) { _roundProcessRepository.Add(round); } try { Save(); } catch (Exception exc) { throw new Exception(exc.Message); } } return(updateProcessResult); }
public async Task <bool> Handle(UpdateInterviewProcessCommand request, CancellationToken cancellationToken) { var interviewProcess = new InterviewProcess(); interviewProcess.Id = request.Id; interviewProcess.FeedbackStatus = request.FeedbackStatus; interviewProcess.EndDate = System.DateTime.Now; var result = await _context.Update(interviewProcess); return(result); }