public async Task Create_Note_Successfully() { var createNote = new CreateNote { Title = "Apples", Content = "Oranges" }; noteService.Setup(x => x.CreateNoteAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(new Note { Id = Guid.NewGuid().ToString(), Title = "Apples", Content = "Oranges", Modified = DateTime.Now, Created = DateTime.Now }); var result = (await controller.Create(createNote)).Result as CreatedResult; var createdNote = (ViewModels.Note)result?.Value; createdNote.Should().NotBeNull(); noteService.Verify(); }
void ParseCreateNote(CreateNote data) { if (data != null) { Log.d("CreateNote", data.ToString()); } }
static void Main(string[] args) { new ENodeFrameworkUnitTestInitializer().Initialize(); //如果要使用Sql或MongoDB来持久化,请用下面相应的语句来初始化 //new ENodeFrameworkSqlInitializer().Initialize(); //new ENodeFrameworkMongoInitializer().Initialize(); //如果要使用Redis来作为内存缓存,请用下面相应的语句来初始化 //new ENodeFrameworkRedisInitializer().Initialize(); var commandService = ObjectContainer.Resolve <ICommandService>(); var memoryCache = ObjectContainer.Resolve <IMemoryCache>(); var noteId = Guid.NewGuid(); var command1 = new CreateNote { NoteId = noteId, Title = "Sample Note" }; var command2 = new ChangeNoteTitle { NoteId = noteId, Title = "Modified Note" }; commandService.Send(command1, (result) => commandService.Send(command2)); Thread.Sleep(1000); Console.WriteLine("Press Enter to exit..."); Console.ReadLine(); }
public AddNotePageViewModel(INoteService noteService, IAccountService accountService) { NoteForm = new CreateNote(); InitializeDependencies(noteService, accountService); InitializeCommands(); NoteForm.CanExecutedChanged = AddCommand.RaiseCanExecuteChanged; }
public object Post(CreateNote request) { var note = new Note { Body = request.Body }; Db.Save(note); return(note); }
private void btnCreateNote_Click(object sender, EventArgs e) { ActivateButton(sender, RGBColors.color2); CreateNote CreateNewNote = new CreateNote(); CreateNewNote.Show(); this.Hide(); }
public async Task <ActionResult <Note> > Create([FromBody] CreateNote note) { logger.LogDebug($"Creating note"); var createdNote = await notesService.CreateNoteAsync(note.Title, note.Content); logger.LogDebug($"Created note: {createdNote.Id}"); return(Created($"api/notes/{createdNote.Id}", new Note(createdNote))); }
public Task <CreateNoteResponse> CreateNote( string contactId, string note, CancellationToken cancellationToken = default) { var parameters = new CreateNoteParams(contactId, note); var function = new CreateNote(parameters); return(CallApi <CreateNoteParams, CreateNoteResponse>(function, cancellationToken)); }
public async Task AddAsync(CreateNote command, Account account) { var note = new Note(command.Title, command.Description) { Account = account }; _context.Notes.Add(note); await _context.SaveChangesAsync(); }
private void btnAddNote_Click(object sender, EventArgs e) { SlidePanel.Height = btnAddNote.Height; SlidePanel.Top = btnAddNote.Top; MainForm.ID_NOTE = 0; CreateNote cn = new CreateNote(); UserControlPanel.Controls.Add(cn); cn.Dock = DockStyle.Fill; cn.BringToFront(); }
public async Task <ActionResult <Note> > Post([FromBody] CreateNote command) { var user = await _userManager.GetUserAsync(HttpContext.User); command.User = user; var note = await _mediator.Send(command); await _mediator.Publish(new NoteCreated( note.Id, command.Title, command.Description )); return(CreatedAtAction(nameof(Get), new { id = note.Id }, note)); }
public ActionResult <Note> Post([FromBody] CreateNote createNote) { var authorizationHeader = Request.Headers["Authorization"]; var user = BasicAuthenticationHandler.GetUserFrom(authorizationHeader); var note = new Note { Author = user.Username, Content = createNote.Content, }; _database.Add(note); _database.SaveChanges(); return(CreatedAtRoute("GetNoteById", new { noteId = note.Id }, note)); }
public async void handlerShouldExecuteCorrectly() { var notesRepo = new Mock <DbSet <Note> >(); notesRepo.Setup(obj => obj.Add(It.IsAny <Note>())).Verifiable(); var context = new Mock <NotepadContext>(new DbContextOptions <NotepadContext>()); context.SetupGet(obj => obj.Notes).Returns(notesRepo.Object).Verifiable(); context.Setup <Task <int> >(obj => obj.SaveChangesAsync(It.IsAny <CancellationToken>())).ReturnsAsync(1).Verifiable(); var handler = new CreateNoteHandler(context.Object); var command = new CreateNote("mytitle", "mydescription"); var result = await handler.Handle(command, new CancellationToken()); notesRepo.Verify(); context.Verify(); Assert.Same(command.Title, result.Title); Assert.Same(command.Description, result.Description); }
public async Task <IActionResult> CreateNoteAsync([FromBody][Required] CreateNote createNote, CancellationToken cancellationToken = default(CancellationToken)) { var hierarchy = await this._documentSession.LoadOrCreateHierarchyAsync(this.User.Identity.Name, cancellationToken); if (createNote.FolderId != null) { var stringFolderId = this._documentSession.ToStringId <Folder>(createNote.FolderId); if (hierarchy.HasFolder(stringFolderId) == false) { createNote.FolderId = null; } } var note = new Note { Title = createNote.Title, Content = createNote.Content, UserId = this.User.Identity.Name, }; await this._documentSession.StoreAsync(note, cancellationToken); hierarchy.AddNewNote(note, this._documentSession.ToStringId <Folder>(createNote.FolderId)); if (hierarchy.Validate() == false) { return(this.BadRequest()); } await this._documentSession.SaveChangesAsync(cancellationToken); var noteDTO = await this._noteToNoteDTOMapper.MapAsync(note, cancellationToken); return(this.CreatedAtRoute(RouteNames.GetNoteById, new { noteId = note.Id }, noteDTO)); }
/// <summary> /// Private ctor /// </summary> private MusicNote() { CreateNote?.Invoke(this, new EventArgs()); }
public async Task <IActionResult> CreateNote([FromBody] CreateNote request) { // var user = // var userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; return(null); }