public async Task CreateMessageFollowup(CorrespondenceFollowupBindingModel model, int senderRole)
        {
            var correspondingNote = db.Notes.SingleOrDefault(n => n.NoteId == model.existingNoteId);

            EDISAngular.Infrastructure.DbFirst.Note note = new EDISAngular.Infrastructure.DbFirst.Note()
            {
                NoteId        = Guid.NewGuid().ToString(),
                AdviserId     = correspondingNote.AdviserId,
                AccountId     = correspondingNote.AccountId,
                AssetClass    = correspondingNote.AssetClass,
                AssetTypeId   = correspondingNote.AssetTypeId,
                Body          = model.body,
                ClientId      = correspondingNote.ClientId,
                DateCompleted = correspondingNote.DateCompleted,
                DateCreated   = DateTime.Now,
                DateDue       = correspondingNote.DateDue,
                DateModified  = DateTime.Now,
                NoteType      = correspondingNote.NoteType,
                Subject       = correspondingNote.Subject,
                SenderRole    = senderRole
            };

            EDISAngular.Infrastructure.DbFirst.NoteLink link = new EDISAngular.Infrastructure.DbFirst.NoteLink()
            {
                DateCreated = DateTime.Now,
                NoteId1     = correspondingNote.NoteId,
                NoteId2     = note.NoteId
            };
            db.Notes.Add(note);
            db.NoteLinks.Add(link);
            await db.SaveChangesAsync();
        }
        public void CreateNewMessageSync(CorrespondenceNoteBindingModel message, int senderRole)
        {
            var resource = db.ResourcesReferences.SingleOrDefault(r => r.TokenValue == message.resourceToken);

            EDISAngular.Infrastructure.DbFirst.Note note = new EDISAngular.Infrastructure.DbFirst.Note()
            {
                AccountId       = "",
                AdviserId       = message.adviserNumber,
                AssetTypeId     = message.assetTypeId,
                Body            = message.body,
                ClientId        = message.clientId,
                DateCompleted   = message.dateCompleted,
                DateCreated     = DateTime.Now,
                DateDue         = message.dateDue,
                DateModified    = DateTime.Now,
                FollowupActions = message.followupActions,
                //FollowupDate = message.followupDate,
                IsAccepted = message.isAccepted,
                IsDeclined = message.isDeclined,
                NoteType   = message.noteTypeId,
                NoteId     = Guid.NewGuid().ToString(),
                Subject    = message.subject,
                SenderRole = senderRole
            };
            db.Notes.Add(note);
            if (!string.IsNullOrEmpty(resource.ResourceUrl))
            {
                EDISAngular.Infrastructure.DbFirst.Attachment attachment = new EDISAngular.Infrastructure.DbFirst.Attachment()
                {
                    AttachmentId   = Guid.NewGuid().ToString(),
                    DateCreated    = DateTime.Now,
                    DateModified   = DateTime.Now,
                    NoteId         = note.NoteId,
                    Path           = resource.ResourceUrl,
                    Title          = note.Subject,
                    AttachmentType = resource.FileExtension
                };
                db.Attachments.Add(attachment);
            }

            db.SaveChanges();
        }
        public void CreateNewMessageSync(CorrespondenceNoteBindingModel message, int senderRole)
        {
            var resource = db.ResourcesReferences.SingleOrDefault(r => r.TokenValue == message.resourceToken);
            EDISAngular.Infrastructure.DbFirst.Note note = new EDISAngular.Infrastructure.DbFirst.Note()
            {
                AccountId = "",
                AdviserId = message.adviserNumber,
                AssetTypeId = message.assetTypeId,
                Body = message.body,
                ClientId = message.clientId,
                DateCompleted = message.dateCompleted,
                DateCreated = DateTime.Now,
                DateDue = message.dateDue,
                DateModified = DateTime.Now,
                FollowupActions = message.followupActions,
                FollowupDate = message.followupDate,
                IsAccepted = message.isAccepted,
                IsDeclined = message.isDeclined,
                NoteType = message.noteTypeId,
                NoteId = Guid.NewGuid().ToString(),
                Subject = message.subject,
                SenderRole = senderRole
            };
            db.Notes.Add(note);
            if (!string.IsNullOrEmpty(resource.ResourceUrl))
            {
                EDISAngular.Infrastructure.DbFirst.Attachment attachment = new EDISAngular.Infrastructure.DbFirst.Attachment()
                {
                    AttachmentId = Guid.NewGuid().ToString(),
                    DateCreated = DateTime.Now,
                    DateModified = DateTime.Now,
                    NoteId = note.NoteId,
                    Path = resource.ResourceUrl,
                    Title = note.Subject,
                    AttachmentType = resource.FileExtension
                };
                db.Attachments.Add(attachment);
            }

            db.SaveChanges();
        }
        public async Task CreateMessageFollowup(CorrespondenceFollowupBindingModel model, int senderRole)
        {
            var correspondingNote = db.Notes.SingleOrDefault(n => n.NoteId == model.existingNoteId);
            EDISAngular.Infrastructure.DbFirst.Note note = new EDISAngular.Infrastructure.DbFirst.Note()
            {
                NoteId = Guid.NewGuid().ToString(),
                AdviserId= correspondingNote.AdviserId,
                AccountId = correspondingNote.AccountId,
                AssetClass = correspondingNote.AssetClass,
                AssetTypeId = correspondingNote.AssetTypeId,
                Body = model.body,
                ClientId = correspondingNote.ClientId,
                DateCompleted = correspondingNote.DateCompleted,
                DateCreated = DateTime.Now,
                DateDue = correspondingNote.DateDue,
                DateModified = DateTime.Now,
                NoteType = correspondingNote.NoteType,
                Subject = correspondingNote.Subject,
                SenderRole = senderRole
            };

            EDISAngular.Infrastructure.DbFirst.NoteLink link = new EDISAngular.Infrastructure.DbFirst.NoteLink()
            {
                DateCreated = DateTime.Now,
                NoteId1 = correspondingNote.NoteId,
                NoteId2 = note.NoteId
            };
            db.Notes.Add(note);
            db.NoteLinks.Add(link);
            await db.SaveChangesAsync();
        }