예제 #1
0
        public ResponseViewModel ApproveOrDisapprove(int statusId, int proposalId)
        {
            var result = _proposalRepository.GetProposalStatuses().FirstOrDefault(x => x.Id == statusId);

            if (result == null)
            {
                return(NotFound(ResponseMessageViewModel.INVALID_STATUS, ResponseErrorCodeStatus.INVALID_STATUS));
            }

            var proposal = _proposalRepository.GetProposalBy(proposalId);

            if (proposal == null)
            {
                return(NotFound(ResponseMessageViewModel.INVALID_PROPOSAL, ResponseErrorCodeStatus.INVALID_PROPOSAL));
            }

            var saved = _proposalRepository.ApproveDisApprove(statusId, proposalId);

            return(Ok(_mapper.Map <Proposal, ProposalViewModel>(saved)));
        }