Example #1
0
        public ActionResult Detail(Guid id)
        {
            try
            {
                var viewModel           = new FarContractViewModel();
                var requiredList        = new List <FarContractDetail>();
                var applicableList      = new List <FarContractDetail>();
                var contractQuestionary = new ContractQuestionaireViewModel();


                Guid farContractType    = _contractService.GetFarContractTypeGuidById(id);
                var  farContractModel   = _farContractTypeService.GetById(farContractType);
                var  requiredListData   = _farContractService.GetRequiredData(id, farContractType);
                var  applicableListData = _farContractService.GetSelectedData(id, farContractType);
                requiredList   = requiredListData;
                applicableList = applicableListData;


                var contractQuestionaireEntity = _contractQuestionariesService.GetContractQuestionariesById(id);
                var contractQuestionaireModel  = _mapper.Map <ContractQuestionaireViewModel>(contractQuestionaireEntity);

                viewModel.ContractGuid          = id;
                viewModel.ContractQuestionaires = contractQuestionary;
                viewModel.RequiredFarClauses    = requiredList;
                viewModel.ApplicableFarClauses  = applicableList;
                viewModel.FarContractTypeCode   = farContractModel.Code;
                viewModel.FarContractTypeName   = farContractModel.Title;

                if (contractQuestionaireModel != null)
                {
                    contractQuestionary = contractQuestionaireModel;
                    var users = _userService.GetUserByUserGuid(contractQuestionaireModel.UpdatedBy);
                    viewModel.UpdatedBy             = users != null ? users.DisplayName : "";
                    viewModel.UpdatedOn             = contractQuestionaireModel.UpdatedOn;
                    viewModel.ContractQuestionaires = contractQuestionary;
                }
                viewModel.Questionniare = _contractQuestionariesService.GetContractQuestionaries(ResourceType.FarContract.ToString(), "Edit", id).ToList();
                return(PartialView(viewModel));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(PartialView());
            }
        }
Example #2
0
        private FarContractViewModel GetFarContract(Guid contractGuid)
        {
            var viewModel           = new FarContractViewModel();
            var requiredList        = new List <FarContractDetail>();
            var applicableList      = new List <FarContractDetail>();
            var contractQuestionary = new ContractQuestionaireViewModel();

            Guid farContractType    = _contractRefactorService.GetFarContractTypeGuidById(contractGuid);
            var  farContractModel   = _farContractTypeService.GetById(farContractType);
            var  requiredListData   = _farContractService.GetRequiredData(contractGuid, farContractType);
            var  applicableListData = _farContractService.GetSelectedData(contractGuid, farContractType);

            requiredList   = requiredListData;
            applicableList = applicableListData;


            var contractQuestionaireEntity = _contractQuestionariesService.GetContractQuestionariesById(contractGuid);
            var contractQuestionaireModel  = _mapper.Map <ContractQuestionaireViewModel>(contractQuestionaireEntity);

            viewModel.ContractGuid          = contractGuid;
            viewModel.ContractQuestionaires = contractQuestionary;
            viewModel.RequiredFarClauses    = requiredList;
            viewModel.ApplicableFarClauses  = applicableList;

            if (farContractModel != null)
            {
                viewModel.FarContractTypeCode = farContractModel.Code;
                viewModel.FarContractTypeName = farContractModel.Title;
            }
            if (contractQuestionaireModel != null)
            {
                contractQuestionary = contractQuestionaireModel;
                var users = _userService.GetUserByUserGuid(contractQuestionaireModel.UpdatedBy);
                viewModel.UpdatedBy = users != null ? users.DisplayName : "";
                viewModel.UpdatedOn = contractQuestionaireModel.UpdatedOn;
            }

            var hasAnyQA = _questionaireUserAnswerService.CheckQAByContractGuid(contractGuid);

            if (hasAnyQA)
            {
                viewModel.Questionniare = _contractQuestionariesService.GetContractQuestionaries(ResourceType.FarContract.ToString(), "Edit", contractGuid).ToList();
            }
            return(viewModel);
        }