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();
        }
예제 #2
0
        public IHttpActionResult followUp(CorrespondenceFollowupBindingModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                var senderRole = User.IsInRole(AuthorizationRoles.Role_Adviser) ?
                                 BusinessLayerParameters.correspondenceSenderRole_adviser
                            : BusinessLayerParameters.correspondenceSenderRole_client;
                CorrespondenceFollowup message = new CorrespondenceFollowup {
                    existingNoteId = model.existingNoteId,
                    body           = model.body
                };

                edisRepo.CreateMessageFollowup(message, senderRole);
                return(Ok());
            }
            else
            {
                if (model == null)
                {
                    ModelState.AddModelError("", "Model is not provided");
                }
                return(BadRequest(ModelState));
            }
        }