コード例 #1
0
        public async Task <ActionResult> PutChildNote(Guid parentNoteId, [FromBody] NoteUpdate value)
        {
            var result = await _noteService.AddChildNote(parentNoteId, value);

            if (result.IsError)
            {
                result.StatuCode = 400;
                return(BadRequest(result));
            }
            return(Ok(result));
        }
コード例 #2
0
            public void PutsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new NotesClient(connection);

                var editNote = new NoteUpdate {
                    Content = "content"
                };

                client.Edit(123, editNote);

                connection.Received().Put <Note>(Arg.Is <Uri>(u => u.ToString() == "notes/123"),
                                                 Arg.Is <NoteUpdate>(d => d.Content == "content"));
            }
コード例 #3
0
ファイル: NoteService.cs プロジェクト: raj70/MyApplication
        public async Task <Result> AddChildNote(Guid noteId, NoteUpdate note)
        {
            var result = await Task.Run(() =>
            {
                var result = new Result();

                var existed_note = _noteRepository.Find(x => x.Id == noteId).FirstOrDefault();
                if (existed_note == null)
                {
                    result.IsError   = true;
                    result.Message   = "Note does not exist";
                    result.StatuCode = 400;
                }
                else
                {
                    var c = note.CreateNote();

                    var new_note = new Note()
                    {
                        ContactId    = existed_note.ContactId,
                        CreatedDate  = existed_note.CreatedDate,
                        UpdatedDate  = c.UpdatedDate,
                        ShortNote    = c.ShortNote,
                        ParentNoteId = existed_note.Id
                    };

                    try
                    {
                        _noteRepository.Add(new_note);
                    }
                    catch (CrmException ex)
                    {
                        result.IsError   = true;
                        result.Message   = ex.Message;
                        result.StatuCode = 400;
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                return(result);
            });

            return(result);
        }
コード例 #4
0
ファイル: WebSyncServer.cs プロジェクト: grepory/tomboy
        public IDictionary <string, NoteUpdate> GetNoteUpdatesSince(int revision)
        {
            Dictionary <string, NoteUpdate> updates =
                new Dictionary <string, NoteUpdate> ();
            int?latestRevision;
            IList <NoteInfo> serverNotes = user.GetNotes(true, revision, out latestRevision);

            VerifyLatestSyncRevision(latestRevision);
            foreach (NoteInfo noteInfo in serverNotes)
            {
                string     noteXml = NoteConvert.ToNoteXml(noteInfo);
                NoteUpdate update  = new NoteUpdate(noteXml,
                                                    noteInfo.Title,
                                                    noteInfo.Guid,
                                                    noteInfo.LastSyncRevision.Value);
                updates.Add(noteInfo.Guid, update);
            }
            return(updates);
        }
コード例 #5
0
        public async Task <Unit> Handle(UpdateNoteCommand request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            using IReturnDbContext editDbContext = this._returnDbContext.CreateForEditContext();

            Note?note = await editDbContext.Notes
                        .Include(x => x.Retrospective)
                        .Include(x => x.Participant)
                        .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken);

            if (note == null)
            {
                throw new NotFoundException(nameof(Note), request.Id);
            }

            // Validate operation
            await this._securityValidator.EnsureAddOrUpdate(note.Retrospective, note);

            // Update the note
            note.Text = request.Text ?? String.Empty;

            await editDbContext.SaveChangesAsync(cancellationToken);

            var notification = new NoteUpdatedNotification(NoteUpdate.FromNote(note));

            if (note.Retrospective.CurrentStage == RetrospectiveStage.Writing)
            {
                notification = new NoteUpdatedNotification(new NoteUpdate(note.Id, this._textAnonymizingService.AnonymizeText(notification.Note.Text)));
            }

            await this._mediator.Publish(notification, cancellationToken);

            return(Unit.Value);
        }
コード例 #6
0
ファイル: NoteController.cs プロジェクト: DSroD/todo-list-api
        //[EnableCors("AnyOrigin")]
        public ActionResult <NoteUpdate> UpdateText(int id, NoteUpdate item)
        {
            if ((item.noteText == null || item.noteText == "") && item.finished == null)
            {
                return(BadRequest());
            }

            var gr = _clusterClient.GetGrain <INoteGrain>(id);

            if (gr.getNote().Result == "")
            {
                return(StatusCode(304));
            }
            if (item.noteText != null && item.noteText != "")
            {
                gr.setNote(item.noteText);
            }
            if (item.finished != null)
            {
                gr.setFinished(item.finished ?? gr.getFinished().Result);
            }

            return(Accepted());
        }