public async Task <CandidateSubmissionSpendViewModel> InsertCandidateExpenseSpent(CandidateSubmissionSpendViewModel data) { try { foreach (var a in data.Files) { CandidateSubmissionSpendFilesViewModel submittedfiles = new CandidateSubmissionSpendFilesViewModel(); var file = await Task.Run(() => ManageCandidate.InsertFiles(a.ConvertTotblFile())); submittedfiles.FileID = file.ID; submittedfiles.createdUserID = a.createdUserID; submittedfiles.createdTimestamp = a.createdTimestamp; submittedfiles.updatedTimestamp = a.updatedTimestamp; submittedfiles.updatedUserID = a.updatedUserID; data.CandidateSubmissionSpendFiles.Add(submittedfiles); } tblCandidateSubmissionSpend res = await Task.Run(() => ManageCandidateSubmissionSpend.InsertCandidateSubmissionSpend(data.ConvertTotblCandidateSubmissionSpend())); return(res.ConvertToCandidateSubmissionSpendViewModel()); } catch (Exception ex) { throw; } }
public async Task <CandidateSubmissionSpendViewModel> UpdateCandidateExpenseSpent(CandidateSubmissionSpendViewModel data) { try { foreach (var a in data.Files) { CandidateSubmissionSpendFilesViewModel submittedfiles = new CandidateSubmissionSpendFilesViewModel(); var file = await Task.Run(() => ManageCandidate.InsertFiles(a.ConvertTotblFile())); submittedfiles.FileID = file.ID; submittedfiles.createdUserID = a.createdUserID; submittedfiles.createdTimestamp = a.createdTimestamp; submittedfiles.updatedTimestamp = a.updatedTimestamp; submittedfiles.updatedUserID = a.updatedUserID; data.CandidateSubmissionSpendFiles.Add(submittedfiles); } await Task.Run(() => ManageCandidateSubmissionSpendFiles.DeleteCandidateSubmissionSpendFiles(data.ID)); data.CandidateSubmissionSpendFiles.All(x => { x.SpendID = data.ID; return(true); }); tblCandidateSubmissionSpend res = await Task.Run(() => ManageCandidateSubmissionSpend.UpdateCandidateSubmissionSpend(data.ConvertTotblCandidateSubmissionSpend())); List <tblCandidateSubmissionSpendFile> submittedFiles = await Task.Run(() => ManageCandidateSubmissionSpendFiles.InsertCandidateSubmissionSpendFiles(data.CandidateSubmissionSpendFiles.Select(x => x.ConvertTotblCandidateSubmissionSpendFile()).ToList())); data.CandidateSubmissionSpendFiles = submittedFiles.Select(x => x.ConvertToCandidateSubmissionSpendFilesViewModel()).ToList(); return(data); } catch (Exception) { throw; } }