public Note UpdateNoteBulkData(int noteId, int accountId, IEnumerable <int> contactIds) { Note note = noteRepository.GetNoteById(noteId, accountId); Logger.Current.Verbose("Indexing contacts mapped to noteid: " + noteId); if (contactIds.IsAny()) { List <LastTouchedDetails> details = new List <LastTouchedDetails>(); foreach (var id in contactIds) { LastTouchedDetails detail = new LastTouchedDetails(); detail.ContactID = id; detail.LastTouchedDate = DateTime.UtcNow; details.Add(detail); } updateLastTouchedInformation(details); } accountService.InsertIndexingData(new InsertIndexingDataRequest() { IndexingData = new Domain.Accounts.IndexingData() { EntityIDs = contactIds.ToList(), IndexType = (int)IndexType.Contacts } }); Logger.Current.Verbose("Indexing contacts successfully noteid: " + noteId); this.addToTopic(note, accountId); return(note); }
public SaveNoteResponse InsertNote(SaveNoteRequest request) { Logger.Current.Verbose("Request for inserting Note"); Logger.Current.Informational("Note details:" + request.NoteViewModel.NoteDetails); Note note = Mapper.Map <NoteViewModel, Note>(request.NoteViewModel); isNoteValid(note); noteRepository.Insert(note); Note newNote = unitOfWork.Commit() as Note; foreach (Tag tag in note.Tags.Where(t => t.Id == 0)) { if (tag.Id == 0) { Tag savedTag = tagRepository.FindBy(tag.TagName, request.AccountId); indexingService.IndexTag(savedTag); accountService.ScheduleAnalyticsRefresh(savedTag.Id, (byte)IndexType.Tags); } } note.Id = newNote.Id; if (request.NoteViewModel.Contacts != null && request.NoteViewModel.Contacts.Count() > 0) { var noteContactIds = request.NoteViewModel.Contacts.Select(c => c.Id).ToList(); List <LastTouchedDetails> details = new List <LastTouchedDetails>(); foreach (var id in noteContactIds) { LastTouchedDetails detail = new LastTouchedDetails(); detail.ContactID = id; detail.LastTouchedDate = DateTime.UtcNow; details.Add(detail); } updateLastTouchedInformation(details); contactService.ContactIndexing(new ContactIndexingRequest() { ContactIds = noteContactIds, Ids = noteContactIds.ToLookup(o => o, o => { return(true); }) }); } if (note.SelectAll == false) { this.addToTopic(note, request.AccountId); } return(new SaveNoteResponse() { NoteViewModel = new NoteViewModel() { NoteId = newNote.Id } }); }