public ApprovalTransactionViewModel AddApprovalTransaction(EntityAndApprovalViewModel entityAndApprovalViewModel)
        {
            var approvalTransaction = new ApprovalTransactions();

            approvalTransaction.MapAuditColumns((ClaimsIdentity)_principal.Identity);

            var approvalTransactionViewModel = entityAndApprovalViewModel.approvalTransactionViewModel;

            approvalTransaction.ApprovalId       = approvalTransactionViewModel.ApprovalId;
            approvalTransaction.ApprovalActionId = approvalTransactionViewModel.ApprovalActionId;
            if (entityAndApprovalViewModel.openingViewModel != null)
            {
                approvalTransaction.EntityId = entityAndApprovalViewModel.openingViewModel.OpeningId;
            }
            else
            {
                approvalTransaction.EntityId = entityAndApprovalViewModel.candidateViewModel.CandidateId;
            }
            approvalTransaction.EntityType = 0;
            if (approvalTransactionViewModel.NextEventOrderNumber < 0)
            {
                approvalTransaction.NextEventOrderNumber = approvalTransactionViewModel.NextEventOrderNumber;
            }
            else
            {
                approvalTransaction.EventOrderNumber     = approvalTransactionViewModel.ApprovalEventOrder;
                approvalTransaction.NextEventOrderNumber = approvalTransaction.EventOrderNumber + 1;
            }

            var approvalTransactionDetail = new ApprovalTransactionDetails();

            approvalTransactionDetail.MapAuditColumns((ClaimsIdentity)_principal.Identity);
            approvalTransactionDetail.Comments         = approvalTransactionViewModel.Comments;
            approvalTransactionDetail.ApprovalActionId = approvalTransaction.ApprovalActionId;
            approvalTransactionDetail.EventOrderNumber = approvalTransaction.EventOrderNumber;
            approvalTransaction.ApprovalTransactionDetails.Add(approvalTransactionDetail);
            _approvalRepository.CreateApprovalTransaction(approvalTransaction);
            approvalTransactionViewModel.MapFromModel(approvalTransaction);
            var userId = GenericHelper.GetUserClaimDetails((ClaimsIdentity)_principal.Identity).UserId;

            if (entityAndApprovalViewModel.candidateViewModel != null)
            {
                _candidateRepository.OnInterviewFinished(approvalTransaction, userId);
            }

            return(approvalTransactionViewModel);
        }