public List <TacticCampaign> GetTacticBySubCampaignId(TacticCampaignViewModel model) { List <TacticCampaign> tacticlist = new List <TacticCampaign>(); ChildCampaign child = guow.GenericRepository <ChildCampaign>().GetByID(model.ChildCampaign_Id); tacticlist.AddRange(child.TacticCampaigns); return(tacticlist); }
public TacticCampaign InsertTacticCampaign(TacticCampaignViewModel model) { var tacticCampaignEntity = new TacticCampaign(); ModelToEntity(model, tacticCampaignEntity); guow.GenericRepository <TacticCampaign>().Insert(tacticCampaignEntity); UpdateInheritStatus(model.MasterCampaign_Id, model.ChildCampaign_Id); return(tacticCampaignEntity); }
public TacticCampaign Update(TacticCampaignViewModel model) { var tacticCamp = LoadTacticEntity(model.Id); tacticCamp = FlushChildRecords(tacticCamp); ModelToEntity(model, tacticCamp); guow.GenericRepository <TacticCampaign>().Update(tacticCamp); UpdateInheritStatus(model.MasterCampaign_Id, model.ChildCampaign_Id); return(tacticCamp); }
//Manage SelectUnselect public TacticCampaignViewModel ManageSelectUnselect(TacticCampaignViewModel model) { if ((model.BusinessGroups_Id != null && (model.BusinessGroupViewModels.ToList().Count > model.BusinessGroups_Id.Length)) || model.BusinessGroups_Id == null || model.BusinessGroups_Id[0] == 0) { model.BgSelectUnselect = false; } else { model.BgSelectUnselect = true; } if ((model.BusinessLines_Id != null && (model.BusinessLineViewModels.ToList().Count > model.BusinessLines_Id.Length)) || model.BusinessLines_Id == null) { model.BlSelectUnselect = false; } else { model.BlSelectUnselect = true; } if ((model.Segments_Id != null && (model.SegmentViewModels.ToList().Count > model.Segments_Id.Length)) || model.Segments_Id == null || model.Segments_Id[0] == 0) { model.SegSelectUnselect = false; } else { model.SegSelectUnselect = true; } if ((model.Industries_Id != null && (model.IndustryViewModels.ToList().Count > model.Industries_Id.Length)) || model.Industries_Id == null) { model.IndustrySelectUnselect = false; } else { model.IndustrySelectUnselect = true; } if ((model.Themes_Id != null && (model.ThemeViewModels.ToList().Count > model.Themes_Id.Length)) || model.Themes_Id == null) { model.ThemeSelectUnselect = false; } else { model.ThemeSelectUnselect = true; } if ((model.Geographys_Id != null && (model.GeographyViewModels.ToList().Count > model.Geographys_Id.Length)) || model.Geographys_Id == null) { model.GeoSelectUnselect = false; } else { model.GeoSelectUnselect = true; } return(model); }
public ActionResult LoadMasterCampaign(TacticCampaignViewModel model) { model.JourneyStageViewModels = _journeyStageServices.GetJourneyStage().ToList(); model.BusinessGroupViewModels = (new[] { new BusinessGroup() }); model.SegmentViewModels = (new[] { new Segment() }); model.Medium = _digitalTouchpoint.GetMedium(); model.Source = _digitalTouchpoint.GetSource(); //If sub campaign is defined for corressponding master campaign if (model.MasterCampaign_Id != 0) { List <ChildCampaign> masterChild = _childCampaignServices .GetChildCampaignByMasterId(model.MasterCampaign_Id).Where(t => t.Status == Status.Complete.ToString()).ToList(); if (masterChild.Count > 0) { model.ChildCampaignViewModels = masterChild; } } ManageSelectUnselect(model); model.MasterViewModels = _masterCampaignServices.GetOrderedMasterCampaign() .Where(t => t.Status == Status.Complete.ToString() && t.ChildCampaigns.Where(r => r.Status != Status.Draft.ToString()).ToList().Count != 0) .ToList(); if (model.MasterCampaign_Id != 0) { model.ChildCampaignViewModels = _childCampaignServices .GetChildCampaignByMasterId(model.MasterCampaign_Id).Where(t => t.Status == Status.Complete.ToString()).ToList(); } var ttList = _tacticCampaignServices.GetTacticType(); model.TacticTypeViewModels = model.TacticTypeViewModels.Concat(ttList).ToList(); model.MetricReachViewModels = _metricReachServices.GetAllMetricReach().ToList(); model.MetricResponseViewModels = _metricResponseServices.GetAllMetricResponse().ToList(); TacticCampaign tacticCampaign = _tacticCampaignServices.GetTacticCampaignById(new TacticCampaignViewModel { Id = model.Id }).FirstOrDefault(); if (tacticCampaign != null) { model.TacticType = tacticCampaign.TacticType; } return(PartialView("TacticCampaignForm", model)); }
private bool isValid(TacticCampaignViewModel model) { int errorCounter = 0; TacticCampaignReachResponse tacticReachModel = model.TacticCampaignReachResponseViewModels.Where(x => x.MetricType == "Reach").FirstOrDefault(); TacticCampaignReachResponse tacticResponseModel = model.TacticCampaignReachResponseViewModels.Where(x => x.MetricType == "Response").FirstOrDefault(); if (model.Id != 0) { if (model.MasterCampaign_Id == 0) { errorCounter++; } if (model.ChildCampaign_Id == 0) { errorCounter++; } if (Convert.ToDateTime(model.StartDate) > Convert.ToDateTime(model.EndDate)) { errorCounter++; } if (model.TacticDescription == "") { errorCounter++; } if (model.StartDate == null) { errorCounter++; } if (model.EndDate == null) { errorCounter++; } if (model.StartDate != null && model.EndDate != null) { if (model.StartDate != null && model.EndDate != null) { if (model.StartDate < model.MCStartDate || model.EndDate > model.MCEndDate) { errorCounter++; } } } } else { if (model.MasterCampaign_Id == 0) { errorCounter++; } if (model.ChildCampaign_Id == 0) { errorCounter++; } if (model.BusinessGroups_Id == null) { errorCounter++; } if (model.BusinessLines_Id == null) { errorCounter++; } if (model.Segments_Id == null) { errorCounter++; } if (Convert.ToDateTime(model.StartDate) > Convert.ToDateTime(model.EndDate)) { errorCounter++; } if (model.Name == "") { errorCounter++; } if (model.TacticDescription == "") { errorCounter++; } if (model.StartDate == null) { errorCounter++; } if (model.EndDate == null) { errorCounter++; } if (model.StartDate != null && model.EndDate != null) { if (model.StartDate != null && model.EndDate != null) { if (model.StartDate < model.MCStartDate || model.EndDate > model.MCEndDate) { errorCounter++; } } } } return(errorCounter == 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)); }
public ActionResult LoadChildCampaign(TacticCampaignViewModel model) { model.Medium = _digitalTouchpoint.GetMedium(); model.Source = _digitalTouchpoint.GetSource(); if (model.ChildCampaign_Id != 0) { model.Segments_Id = null; model.BusinessGroups_Id = null; model.Industries_Id = null; model.BusinessLines_Id = null; List <ChildCampaign> valueChild = _childCampaignServices.GetChildCampaignById( new ChildCampaignViewModel { Id = model.ChildCampaign_Id }); foreach (var item in valueChild) { if (item.CampaignType == 0) { model.BusinessGroupViewModels = model.BusinessGroupViewModels.Concat(item.BusinessGroups).ToList(); model.SegmentViewModels = item.Segments.ToList(); } else { model.BusinessGroupViewModels = item.BusinessGroups.ToList(); model.SegmentViewModels = model.SegmentViewModels.Concat(item.Segments).ToList(); } if (model.Segments_Id != null) { if (model.Segments_Id[0] != 0 && model.Segments_Id[0] != -1) { model.IndustryViewModels = item.Industries.ToList(); } } else { model.Industries_Id = null; } if (model.BusinessGroups_Id != null) { if (model.BusinessGroups_Id[0] != 0 && model.BusinessGroups_Id[0] != -1) { model.BusinessLineViewModels = item.BusinessLines.ToList(); } } else { model.BusinessLines_Id = null; } model.ThemeViewModels = item.Themes.ToList(); model.GeographyViewModels = item.Geographys.ToList(); model.MCStartDate = item.StartDate; model.MCEndDate = item.EndDate; model.SubCampaignType = item.CampaignType; } } else { model.BusinessGroupViewModels = (new[] { new BusinessGroup() }); model.SegmentViewModels = (new[] { new Segment() }); } model.JourneyStageViewModels = _journeyStageServices.GetJourneyStage().ToList(); model.MasterViewModels = _masterCampaignServices.GetOrderedMasterCampaign().Where(t => t.Status == Status.Complete.ToString() && t.ChildCampaigns.Where(r => r.Status != Status.Draft.ToString()).ToList().Count != 0).ToList(); if (model.MasterCampaign_Id != 0) { model.ChildCampaignViewModels = _childCampaignServices .GetChildCampaignByMasterId(model.MasterCampaign_Id).Where(t => t.Status == Status.Complete.ToString()).ToList(); } var ttList = _tacticCampaignServices.GetTacticType(); model.TacticTypeViewModels = model.TacticTypeViewModels.Concat(ttList).ToList(); TacticCampaign tacticCampaign = _tacticCampaignServices.GetTacticCampaignById(new TacticCampaignViewModel { Id = model.Id }).FirstOrDefault(); if (tacticCampaign != null) { model.TacticType = tacticCampaign.TacticType; } ManageSelectUnselect(model); model.MetricReachViewModels = _metricReachServices.GetAllMetricReach().ToList(); model.MetricResponseViewModels = _metricResponseServices.GetAllMetricResponse().ToList(); return(PartialView("TacticCampaignForm", model)); }
private void ModelToEntity(TacticCampaignViewModel model, TacticCampaign tacticCampaignEntity) { if (tacticCampaignEntity.Status != Status.Complete.ToString()) { tacticCampaignEntity.ChildCampaigns = guow.GenericRepository <ChildCampaign>() .GetByID(model.ChildCampaign_Id); tacticCampaignEntity.ChildCampaigns.MasterCampaigns = guow.GenericRepository <MasterCampaign>() .GetByID(model.MasterCampaign_Id); tacticCampaignEntity.Name = model.Name; tacticCampaignEntity.CreatedBy = "user"; tacticCampaignEntity.Year = model.Year; tacticCampaignEntity.MasterCampaign_Id = model.MasterCampaign_Id; tacticCampaignEntity.JourneyStage_Id = model.JournetStage_Id; tacticCampaignEntity.TacticType = model.TacticType; List <TacticType> lstTacticType = null; if (model.TacticType_Id != null) { lstTacticType = new List <TacticType>(); foreach (var item in model.TacticType_Id) { var tacticType = guow.GenericRepository <TacticType>().GetByID(item); lstTacticType.Add(tacticType); } } tacticCampaignEntity.TacticTypes = lstTacticType; tacticCampaignEntity.TacticCampaignReachResponses = model.TacticCampaignReachResponseViewModels.ToList(); if (model.Id == 0) { tacticCampaignEntity.VisitedDate = DateTime.Now; } } tacticCampaignEntity.InheritStatus = model.Status == Status.Draft.ToString() ? InheritStatus.Draft.ToString() : InheritStatus.Active.ToString(); if (model.Id != 0 && model.Status == Status.Complete.ToString()) { if (model.EndDate < DateTime.Now) { tacticCampaignEntity.InheritStatus = InheritStatus.Complete.ToString(); } } tacticCampaignEntity.Status = model.Status; tacticCampaignEntity.TacticDescription = model.TacticDescription; tacticCampaignEntity.StartDate = model.StartDate; tacticCampaignEntity.EndDate = model.EndDate; tacticCampaignEntity.Vendor = model.Vendor; List <BusinessLine> lstBline = null; List <BusinessGroup> lstBGroup = null; if (model.BusinessGroups_Id != null) { lstBGroup = new List <BusinessGroup>(); foreach (var item in model.BusinessGroups_Id) { var Bgroups = guow.GenericRepository <BusinessGroup>().GetByID(item); lstBGroup.Add(Bgroups); } lstBline = new List <BusinessLine>(); if (model.BusinessLines_Id != null) { foreach (var item in model.BusinessLines_Id) { var Bline = guow.GenericRepository <BusinessLine>().GetByID(item); lstBline.Add(Bline); } } } List <Theme> lsttheme = null; if (model.Themes_Id != null) { lsttheme = new List <Theme>(); foreach (var item in model.Themes_Id) { var theme = guow.GenericRepository <Theme>().GetByID(item); lsttheme.Add(theme); } } List <Industry> lstindustry = null; List <Segment> lstsegment = null; if (model.Segments_Id != null) { lstsegment = new List <Segment>(); foreach (var item in model.Segments_Id) { var segment = guow.GenericRepository <Segment>().GetByID(item); lstsegment.Add(segment); } lstindustry = new List <Industry>(); if (model.Industries_Id != null) { foreach (var item in model.Industries_Id) { var industry = guow.GenericRepository <Industry>().GetByID(item); lstindustry.Add(industry); } } } List <Geography> lstgeography = null; if (model.Geographys_Id != null) { lstgeography = new List <Geography>(); foreach (var item in model.Geographys_Id) { var geography = guow.GenericRepository <Geography>().GetByID(item); lstgeography.Add(geography); } } List <Vendor> lstvendor = null; if (model.Vendor_Id != null) { lstvendor = new List <Vendor>(); foreach (var item in model.Vendor_Id) { var vendor = guow.GenericRepository <Vendor>().GetByID(item); lstvendor.Add(vendor); } } tacticCampaignEntity.BusinessGroups = lstBGroup; tacticCampaignEntity.Themes = lsttheme; tacticCampaignEntity.BusinessLines = lstBline; tacticCampaignEntity.Segments = lstsegment; tacticCampaignEntity.Industries = lstindustry; tacticCampaignEntity.Geographys = lstgeography; }
public List <TacticCampaign> GetTacticCampaignById(TacticCampaignViewModel model) { List <TacticCampaign> tacticCampaign = guow.GenericRepository <TacticCampaign>().GetAllIncluding((t => t.Geographys), (m => m.Industries), (m => m.BusinessGroups), (m => m.BusinessLines), (m => m.Segments), (m => m.Themes), (m => m.TacticTypes)).Where(t => t.Id == model.Id).ToList(); return(tacticCampaign); }