コード例 #1
0
        /// <summary>
        /// Get SegmentHierarchy
        /// </summary>
        /// <returns>
        /// It returns segmnent hierarchy
        /// </returns>
        /// <Written By>
        /// Faizan Ahmad
        /// </Written>
        public JsonResult GetSegmentHierarchy()
        {
            SegmentHierarchy SegmentHierarchy = new SegmentHierarchy();

            try
            {
                SegmentHierarchy.SegmentHierarchyLst = (from seg in _segmentServices.GetSegment()
                                                        join Industry in _industryServices.GetIndustry()
                                                        on seg.Id equals Industry.Segments.Id
                                                        select
                                                        new SegmentHierarchy.SegmentHierarchyList
                {
                    SegmentId = seg.Id,
                    SegmentName = seg.Name,
                    IndustryId = Industry.Id,
                    IndustryName = Industry.Name
                }).ToList();

                SegmentHierarchy.IsSuccess = true;
            }
            catch (Exception ex)
            {
                SegmentHierarchy.IsSuccess = false;
            }
            return(Json(SegmentHierarchy.SegmentHierarchyLst, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public async Task ReturnCorrectIndustry_WhenParamsAreValid()
        {
            //Arrange
            var options  = Utils.GetOptions(nameof(ReturnCorrectIndustry_WhenParamsAreValid));
            var industry = TestModelsSeeder.SeedIndustry();

            using (var arrangeContext = new InsightHubContext(options))
            {
                await arrangeContext.AddAsync(industry);

                await arrangeContext.SaveChangesAsync();
            }
            //Act & Assert
            using var assertContext = new InsightHubContext(options);
            var sut    = new IndustryServices(assertContext);
            var result = await sut.GetIndustry(1);

            Assert.AreEqual(industry.Id, result.Id);
            Assert.AreEqual(industry.Name, result.Name);
        }
コード例 #3
0
        public ActionResult TacticCampaign(int Id = 0)
        {
            TacticCampaignViewModel tacticvm = new TacticCampaignViewModel();

            tacticvm.JourneyStageViewModels = _journeyStageServices.GetJourneyStage().ToList();
            var ttList = _tacticCampaignServices.GetTacticType().ToList();

            tacticvm.TacticTypeViewModels = tacticvm.TacticTypeViewModels.Concat(ttList).ToList();
            tacticvm.MasterViewModels     = _masterCampaignServices.GetOrderedMasterCampaign().Where(t => t.Status == Status.Complete.ToString() && t.ChildCampaigns.Where(r => r.Status != Status.Draft.ToString()).ToList().Count != 0).ToList();
            tacticvm.Medium = _digitalTouchpoint.GetMedium();
            tacticvm.Source = _digitalTouchpoint.GetSource();
            if (Id == 0)
            {
                tacticvm.BusinessGroupViewModels  = (new[] { new BusinessGroup() });
                tacticvm.SegmentViewModels        = (new[] { new Segment() });
                tacticvm.MetricReachViewModels    = _metricReachServices.GetAllMetricReach().ToList();
                tacticvm.MetricResponseViewModels = _metricResponseServices.GetAllMetricResponse().ToList();

                return(View(tacticvm));
            }

            if (Id != 0)
            {
                TacticCampaign tacticCampaign = _tacticCampaignServices.GetTacticCampaignById(new TacticCampaignViewModel {
                    Id = Id
                }).First();

                tacticvm.ChildCampaignViewModels = _childCampaignServices.GetChildCampaignByMasterId(tacticCampaign.ChildCampaigns.MasterCampaigns.Id).Where(t => t.Status == Status.Complete.ToString()).ToList();

                if (tacticCampaign.ChildCampaigns.Id != 0)
                {
                    List <ChildCampaign> childCampaign = _childCampaignServices.GetDDLValuesByChildId(tacticCampaign.ChildCampaigns.Id);
                    foreach (var item in childCampaign)
                    {
                        if (item.CampaignType == 0)
                        {
                            tacticvm.BusinessGroupViewModels = tacticvm.BusinessGroupViewModels.Concat(item.BusinessGroups).ToList();
                            tacticvm.SegmentViewModels       = item.Segments.ToList();
                        }
                        else
                        {
                            tacticvm.BusinessGroupViewModels = item.BusinessGroups.ToList();
                            tacticvm.SegmentViewModels       = tacticvm.SegmentViewModels.Concat(item.Segments).ToList();
                        }
                        tacticvm.ThemeViewModels        = item.Themes.ToList();
                        tacticvm.GeographyViewModels    = item.Geographys.ToList();
                        tacticvm.BusinessLineViewModels = item.BusinessLines.ToList();
                        tacticvm.IndustryViewModels     = item.Industries.ToList();
                        tacticvm.MCStartDate            = item.StartDate;
                        tacticvm.MCEndDate = item.EndDate;
                    }
                }
                else
                {
                    tacticvm.IndustryViewModels      = _industryService.GetIndustry().ToList();
                    tacticvm.BusinessGroupViewModels = _businessgroupService.GetBG().ToList();
                    tacticvm.BusinessLineViewModels  = _businesslineService.GetBusinessLine().ToList();
                    tacticvm.SegmentViewModels       = _segmentService.GetSegment().ToList();
                    tacticvm.ThemeViewModels         = _themeService.GetTheme().ToList();
                    tacticvm.GeographyViewModels     = _geographyService.GetGeography().ToList();
                }

                if (tacticCampaign.ChildCampaigns.MasterCampaigns != null && tacticCampaign.ChildCampaigns.MasterCampaigns.Id != 0)
                {
                    tacticvm.MasterCampaign_Id = tacticCampaign.ChildCampaigns.MasterCampaigns.Id;
                }

                if (tacticCampaign.ChildCampaigns != null && tacticCampaign.ChildCampaigns.Id != 0)
                {
                    tacticvm.ChildCampaign_Id = tacticCampaign.ChildCampaigns.Id;
                }

                if (tacticCampaign.Themes != null && tacticCampaign.Themes.Count > 0)
                {
                    tacticvm.Themes_Id = tacticCampaign.Themes.Select(t => t.Id).ToArray();;
                }


                if (tacticCampaign.BusinessGroups != null && tacticCampaign.BusinessGroups.Count > 0)
                {
                    tacticvm.BusinessGroups_Id = tacticCampaign.BusinessGroups.Select(t => t.Id).ToArray();;
                }

                if (tacticCampaign.BusinessLines != null && tacticCampaign.BusinessLines.Count > 0)
                {
                    tacticvm.BusinessLines_Id = tacticCampaign.BusinessLines.Select(t => t.Id).ToArray();;
                }

                if (tacticCampaign.Segments != null && tacticCampaign.Segments.Count > 0)
                {
                    tacticvm.Segments_Id = tacticCampaign.Segments.Select(t => t.Id).ToArray();;
                }

                if (tacticCampaign.Industries != null && tacticCampaign.Industries.Count > 0)
                {
                    tacticvm.Industries_Id = tacticCampaign.Industries.Select(t => t.Id).ToArray();;
                }

                if (tacticCampaign.Geographys != null && tacticCampaign.Geographys.Count > 0)
                {
                    tacticvm.Geographys_Id = tacticCampaign.Geographys.Select(t => t.Id).ToArray();;
                }

                if (tacticCampaign.TacticTypes != null && tacticCampaign.TacticTypes.Count > 0)
                {
                    tacticvm.TacticType_Id = tacticCampaign.TacticTypes.Select(t => t.Id).ToArray();;
                }

                tacticvm.TacticType      = tacticCampaign.TacticType;
                tacticvm.JournetStage_Id = tacticCampaign.JourneyStage_Id;
                tacticvm.Id   = tacticCampaign.Id;
                tacticvm.Name = tacticCampaign.Name;
                tacticvm.TacticDescription = tacticCampaign.TacticDescription;
                tacticvm.StartDate         = tacticCampaign.StartDate;
                tacticvm.EndDate           = tacticCampaign.EndDate;
                tacticvm.Status            = tacticCampaign.Status;
                tacticvm.Vendor            = tacticCampaign.Vendor;
                tacticvm.Year              = tacticCampaign.Year;
                tacticvm.Status            = tacticCampaign.Status;
                tacticvm.MasterCampaign_Id = tacticCampaign.MasterCampaign_Id;

                var MasterCampaignName = string.Empty;
                var ChildCampaignName  = string.Empty;
                foreach (var val in tacticvm.MasterViewModels)
                {
                    if (val.Id == tacticCampaign.MasterCampaign_Id)
                    {
                        MasterCampaignName = val.Name;
                    }
                }
                foreach (var val in tacticvm.ChildCampaignViewModels)
                {
                    if (val.Id == tacticCampaign.ChildCampaigns.Id)
                    {
                        ChildCampaignName = val.Name;
                    }
                }

                if (Tacticvm.EndDate < DateTime.Now)
                {
                    tacticCampaign.InheritStatus = Status.Complete.ToString();
                }

                tacticvm.StatusInheritaceStamp = String.Format("{0:yy}", tacticCampaign.UpdatedDate) + "." + MasterCampaignName + "."
                                                 + ChildCampaignName + " //" + ((tacticvm.Status == Status.Complete.ToString() &&
                                                                                 (tacticvm.EndDate < DateTime.Now)) ? Status.Complete.ToString() : tacticvm.Status) +
                                                 " // " + String.Format("{0:ddMMyy HH:MM}", tacticCampaign.UpdatedDate);


                tacticvm.MetricReachViewModels    = _metricReachServices.GetAllMetricReach().ToList();
                tacticvm.MetricResponseViewModels = _metricResponseServices.GetAllMetricResponse().ToList();
                tacticvm.TacticCampaignReachResponseViewModels = tacticCampaign.TacticCampaignReachResponses.ToList();

                //Update visited date
                if (tacticvm.Status == Status.Draft.ToString())
                {
                    tacticCampaign.VisitedDate = DateTime.Now;
                    _tacticCampaignServices.Update(tacticCampaign);
                }
            }
            return(View(tacticvm));
        }
コード例 #4
0
        public async Task Throw_WhenIdIsInvalid()
        {
            //Arrange
            var options = Utils.GetOptions(nameof(Throw_WhenIdIsInvalid));

            //Act & Assert
            using var assertContext = new InsightHubContext(options);
            var sut = new IndustryServices(assertContext);
            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await sut.GetIndustry(5));
        }