public GetLeadScoreResponse GetLeadScoreRule(GetLeadScoreRequest request)
        {
            GetLeadScoreResponse response = new GetLeadScoreResponse();

            LeadScoreRule leadScoreRule = leadScoreRuleRepository.FindBy(request.Id);

            if (leadScoreRule == null)
            {
                response.Exception = GetLeadScoreNotFoundException();
            }
            else
            {
                LeadScoreRuleViewModel leadScoreRuleViewModel = Mapper.Map <LeadScoreRule, LeadScoreRuleViewModel>(leadScoreRule);
                if ((leadScoreRuleViewModel.ConditionID == LeadScoreConditionType.ContactActionTagAdded || leadScoreRuleViewModel.ConditionID == LeadScoreConditionType.ContactNoteTagAdded ||
                     leadScoreRuleViewModel.ConditionID == LeadScoreConditionType.ContactTagAdded) && leadScoreRuleViewModel.SelectedTagID != null)
                {
                    IEnumerable <Tag>          Tags    = leadScoreRuleRepository.GetTags(leadScoreRuleViewModel.SelectedTagID);
                    IEnumerable <TagViewModel> TagData = Mapper.Map <IEnumerable <Tag>, IEnumerable <TagViewModel> >(Tags);
                    foreach (var tag in TagData)
                    {
                        tag.TagName += " *";
                    }
                    leadScoreRuleViewModel.TagsList = TagData;
                }
                response.LeadScoreViewModel = leadScoreRuleViewModel;
            }
            return(response);
        }
Beispiel #2
0
        public JsonResult GetLeadScoreRule(int leadScoreId)
        {
            GetLeadScoreResponse response = leadScoreService.GetLeadScoreRule(new GetLeadScoreRequest(leadScoreId)
            {
            });

            return(Json(response.LeadScoreViewModel, JsonRequestBehavior.AllowGet));
        }
        public void GetLeadScore_RuntimeException_ExceptionDetails()
        {
            mockLeadScoreRuleRepository.Setup(c => c.FindBy(It.IsAny <int>())).Throws(new InvalidOperationException());

            GetLeadScoreResponse response = leadScoreRuleService.GetLeadScoreRule(new GetLeadScoreRequest(LEAD_SCORE_RULE_ID));

            mockRepository.VerifyAll();
            Assert.AreEqual(typeof(InvalidOperationException), response.Exception.GetType());
            Assert.AreNotEqual(null, response.Exception);
        }
        public void GetLeadScoreRule_ValidRule_Succeed()
        {
            var mockRule = LeadScoreRuleMockData.GetMockLeadScoreRulesWithSetups(mockRepository, 1).FirstOrDefault();

            mockLeadScoreRuleRepository.Setup(cr => cr.FindBy(It.IsAny <int>())).Returns(mockRule.Object);
            mockTagRepository.Setup(c => c.FindByContact(It.IsAny <int>(), It.IsAny <int>())).Returns(new List <Tag>());

            GetLeadScoreResponse response = leadScoreRuleService.GetLeadScoreRule(new GetLeadScoreRequest(1));
            int id = response.LeadScoreViewModel.LeadScoreRuleID;

            mockLeadScoreRuleRepository.VerifyAll();
            Assert.AreEqual(mockRule.Object.Id, id);
            Assert.AreNotEqual(null, response.Exception);
        }
        public ActionResult EditLeadScore(int leadScoreRuleMapId)
        {
            var dropdownValues            = cachingService.GetDropdownValues(this.Identity.ToAccountID());
            GetLeadScoreResponse response = leadScoreService.GetLeadScoreRule(new GetLeadScoreRequest(leadScoreRuleMapId)
            {
            });

            response.LeadScoreViewModel.DateFormat      = this.Identity.ToDateFormat();
            response.LeadScoreViewModel.CreatedOn       = response.LeadScoreViewModel.CreatedOn.ToUserUtcDateTimeV2();
            response.LeadScoreViewModel.LeadsourceTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.LeadSources).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true);
            response.LeadScoreViewModel.TourTypes       = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.TourType).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true);
            response.LeadScoreViewModel.NoteCategories  = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.NoteCategory).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true);
            response.LeadScoreViewModel.ActionTypes     = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.ActionType).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true);
            GetLeadScoreCategoriesResponse categoriesResponse = leadScoreService.GetLeadScoreCategories(new GetLeadScoreCategoriesRequest()
            {
            });

            response.LeadScoreViewModel.Categories = categoriesResponse.Categories;
            GetLeadScoreConditionsResponse conditionsResponce = leadScoreService.GetLeadScoreConditions(new GetLeadScoreConditionsRequest()
            {
            });
            var leadScoreConditionValues = new List <LeadScoreConditionValueViewModel>();
            var newConditionValue        = new LeadScoreConditionValueViewModel()
            {
                LeadScoreConditionValueId = 0,
                LeadScoreRuleId           = 0,
                Value     = "",
                ValueType = LeadScoreValueType.PageDuration
            };

            leadScoreConditionValues.Add(newConditionValue);
            if (!response.LeadScoreViewModel.LeadScoreConditionValues.IsAny())
            {
                response.LeadScoreViewModel.LeadScoreConditionValues = leadScoreConditionValues;
            }


            response.LeadScoreViewModel.Conditions = conditionsResponce.Conditions;
            ViewBag.IsModal = true;
            var view = PartialView("_AddEditRule", response.LeadScoreViewModel);

            return(view);
        }