public virtual ActionResult TaggedEmails(TaggedEmailsModel mm) { if (mm == null) mm = new TaggedEmailsModel(); mm.OrTags = new EmailTagListModel(crmService.GetDistinctTags().Select(t => new TagString() { TagSpace = t.Tagspace, Tag = t.Tag }).ToList()); mm.AndTags = new EmailTagListModel(crmService.GetDistinctTags().Select(t => new TagString() { TagSpace = t.Tagspace, Tag = t.Tag }).ToList()); mm.NotTags = new EmailTagListModel(crmService.GetDistinctTags().Select(t => new TagString() { TagSpace = t.Tagspace, Tag = t.Tag }).ToList()); return View(mm); }
public virtual ActionResult GetTaggedEmails(string OrTags, string AndTags, string NotTags, int? AdremaListId, string AdremaListName, string AdremaListDesc) { var mm = new TaggedEmailsModel(); if (AdremaListId != null && AdremaListName.Empty()) { // Load arema list definition var al = crmService.GetAdremaList(AdremaListId.Value); if (al != null) { AdremaListName = al.Name; AdremaListDesc = al.Description; OrTags = al.OrTags; AndTags = al.AndTags; NotTags = al.NotTags; } } mm.OrTags = new EmailTagListModel(crmService.GetDistinctTags().Select(t => new TagString() { TagSpace = t.Tagspace, Tag = t.Tag }).ToList()); mm.AndTags = new EmailTagListModel(crmService.GetDistinctTags().Select(t => new TagString() { TagSpace = t.Tagspace, Tag = t.Tag }).ToList()); mm.NotTags = new EmailTagListModel(crmService.GetDistinctTags().Select(t => new TagString() { TagSpace = t.Tagspace, Tag = t.Tag }).ToList()); var orTags = new EmailTagListModel(OrTags.SplitToList(",")); var andTags = new EmailTagListModel(AndTags.SplitToList(",")); var notTags = new EmailTagListModel(NotTags.SplitToList(",")); var orTagsArr = orTags.Tags.Select(t => t.FullTag).ToArray(); var andTagsArr = andTags.Tags.Select(t => t.FullTag).ToArray(); var notTagsArr = notTags.Tags.Select(t => t.FullTag).ToArray(); mm.OrTags.InitialTagsList = OrTags; mm.AndTags.InitialTagsList = AndTags; mm.NotTags.InitialTagsList = NotTags; mm.AdremaListId = AdremaListId??0; mm.AdremaListName = AdremaListName; mm.AdremaListDesc = AdremaListDesc; mm.Emails = crmService.GetEmailsForAdrema(orTagsArr, andTagsArr, notTagsArr).ToList().ConcatList(","); // Save adrema list definition if (AdremaListId != null && AdremaListId != 0) { if ((!orTags.Tags.Any() && !andTags.Tags.Any() && !notTags.Tags.Any()) || AdremaListName.Empty()) { crmService.DeleteAdremaList(AdremaListId.Value); } else { crmService.UpdateAdremaList(AdremaListId.Value, AdremaListName, AdremaListDesc, OrTags,AndTags,NotTags); } crmService.SaveChanges(); } else if (AdremaListName.NotEmpty() && AdremaListDesc.NotEmpty()) { Guid guid = Guid.NewGuid(); crmService.InsertAdremaList(guid, AdremaListName, AdremaListDesc,OrTags,AndTags,NotTags); crmService.SaveChanges(); var al2 = crmService.GetAdremaList(guid); mm.AdremaListId = al2.Id; } return View("TaggedEmails",mm); }