public async Task <CandidateSubmissionCreateModel> UpdateCandidateSubmission(CandidateSubmissionCreateModel data) { try { CandidateSubmissionCreateModel model = null; if (data.IsNewCustomer) { CandidateCreateModel candidate = await Task.Run(() => CreateCandidate(data.Candidate)); data.CandidateSubmission.CandidateId = candidate.Candidate.id; } if (data.IsCustomerEdited) { await Task.Run(() => UpdateCandidate(data.Candidate)); } await Task.Run(() => ManageCandidate.UpdateCandidateSubmissions(data.CandidateSubmission.ConverToTblCandidateSubmission())); await Task.Run(() => ManageCandidateSubmissionsQuestionsResponses.DeleteCandidateSubmissionsQuestionsRespons(data.CandidateSubmission.ID)); foreach (VacancyQuestionViewModel vq in data.Questions) { vq.CandidateSubmissionsQuestionsResponse.All(re => { re.createdTimestamp = data.CandidateSubmission.createdTimestamp; re.createdUserID = data.CandidateSubmission.createdUserID; re.updatedUserID = data.CandidateSubmission.updatedUserID; re.updatedTimestamp = data.CandidateSubmission.updatedTimestamp; return(true); }); await Task.Run(() => ManageCandidateSubmissionsQuestionsResponses.InsertCandidateSubmissionsQuestionsRespons(vq.CandidateSubmissionsQuestionsResponse.Select(re => re.ConvertTotblCandidateSubmissionsQuestionsRespons()).ToList())); } await Task.Run(() => ManageCandidateSubmissionDocumentResponses.DeleteCandidateSubmissionDocumentRespons(data.CandidateSubmission.ID)); foreach (VacancyRequiredDocumentViewModel rd in data.RequiredDocument) { rd.CandidateSubmissionDocumentResponse.All(re => { re.createdTimestamp = data.CandidateSubmission.createdTimestamp; re.createdUserID = data.CandidateSubmission.createdUserID; re.updatedUserID = data.CandidateSubmission.updatedUserID; re.updatedTimestamp = data.CandidateSubmission.updatedTimestamp; return(true); }); await Task.Run(() => ManageCandidateSubmissionDocumentResponses.InsertCandidateSubmissionDocumentRespons(rd.CandidateSubmissionDocumentResponse.Select(res => res.ConvertTotblCandidateSubmissionsQuestionsResponses()).ToList())); } return(model); } catch (Exception) { throw; } }
//[ResponseType(typeof(CandidateSubmissionCreateModel))] public async Task <IHttpActionResult> UpdateCandidateSubmission(CandidateSubmissionCreateModel data) { try { string userId = User.Identity.GetUserId(); Helpers.Helpers.AddBaseProperties(data.CandidateSubmission, "create", userId); return(Ok(await CandidateService.UpdateCandidateSubmission(data))); } catch (Exception) { throw; } }