示例#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 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));
        }
示例#3
0
        public ActionResult MasterCampaign(int Id = 0)
        {
            MasterCampaignViewModel mcvm = new MasterCampaignViewModel();

            mcvm.BusinessGroupViewModels = _businessgroupService.GetBG();
            mcvm.SegmentViewModels       = _segmentService.GetSegment();
            mcvm.GeographyViewModels     = _geographyService.GetGeography();
            mcvm.ThemeViewModels         = _themeService.GetTheme();

            if (Id != 0)
            {
                MasterCampaign masterCampaign = _masterCampaignServices.GetMasterCampaignById(new MasterCampaignViewModel {
                    Id = Id
                }).First();

                mcvm.InheritanceStatus = masterCampaign.InheritStatus;

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


                if (masterCampaign.BusinessGroups != null && masterCampaign.BusinessGroups.Count > 0)
                {
                    mcvm.BusinessGroups_Id = masterCampaign.BusinessGroups.Select(t => t.Id).ToArray();;
                    mcvm.BgSelectUnselect  = true;
                }

                mcvm.BusinessLineViewModels = _businesslineService.GetBusinessLineByBGId(mcvm.BusinessGroups_Id);

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


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

                if (masterCampaign.Segments != null && masterCampaign.Segments.Count > 0)
                {
                    mcvm.Segments_Id       = masterCampaign.Segments.Select(t => t.Id).ToArray();;
                    mcvm.SegSelectUnselect = true;
                }

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

                mcvm.IndustryViewModels = _industryService.GetIndustryBySegmentId(mcvm.Segments_Id).Where(t => t.IsActive == true).ToList();


                mcvm.Name = masterCampaign.Name;
                mcvm.CampaignDescription = masterCampaign.CampaignDescription;
                mcvm.CampaignManager     = masterCampaign.CampaignManager;
                if (masterCampaign.StartDate != null)
                {
                    mcvm.StartDate = masterCampaign.StartDate.Value;
                }
                if (masterCampaign.EndDate != null)
                {
                    mcvm.EndDate = masterCampaign.EndDate.Value;
                }
                mcvm.Id     = Id;
                mcvm.Status = masterCampaign.Status;


                mcvm.StatusInheritaceStamp = String.Format("{0:yy}", masterCampaign.UpdatedDate) + "." + mcvm.Name + " //"
                                             + (mcvm.Status == Status.Draft.ToString() ? Status.Draft.ToString() : mcvm.InheritanceStatus) +
                                             " // " + String.Format("{0:ddMMyy HH:MM}", masterCampaign.UpdatedDate);


                ManageSelectUnselect(mcvm);

                //Update visited date
                if (mcvm.Status == Status.Draft.ToString())
                {
                    masterCampaign.VisitedDate = DateTime.Now;
                    _masterCampaignServices.Update(masterCampaign);
                }
            }

            return(View(mcvm));
        }